pls help

liunx

Guest
i'm trying to load in a new page the last entry or entry refered to the max id found in my access database..the problem is it keeps showing the first entry or the entry refered to the min id num...
can anyone help..this is my code to load my page:
Sub Page_Load(sender As Object, e As EventArgs)
label1.text= naharnews().Tables(0).Rows(0)(0)
label2.text= naharnews().Tables(0).Rows(0)(1)
label3.text= naharnews().Tables(0).Rows(0)(2)

databind()
pls, anyone could help!!!!what is your sql statement?ok..my sql statement..

if you mean my connection to my database then it is the following:

Function news() As System.Data.DataSet
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\my last\mydat"& _
"abase.mdb"
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)

Dim queryString As String = "SELECT [updatetable].[local1], [updatetable].[local2], [updatetable].[analyze] FR"& _
"OM [updatetable]"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)

Return dataSet
End Function

The above was a connection and then comes:

Sub Page_Load(sender As Object, e As EventArgs)
label1.text= naharnews().Tables(0).Rows(0)(0)
label2.text= naharnews().Tables(0).Rows(0)(1)
label3.text= naharnews().Tables(0).Rows(0)(2)

databind()
End Sub

that loads my page.

Other than that i have no sql statement cus i thought i don't need it...I just used the page_load to load the content from the database but the problem is that as i said before it keeps reading the entry referred to the oldest ID. whereas, i need the opposite.

Yes, i thought of having an sql statement so i can specify a condition of taking the maximum id...

but i don't know where to display it...
there should be something...
thanks alot...your query string is your sql....

"SELECT [updatetable].[local1], [updatetable].[local2], [updatetable].[analyze] FR"& _
"OM [updatetable] ORDER BY [updatetable].[local1] DESC"

not sure what your id column is so I just picked one.....

Erici'm trying to load in a new page the last entry or entry refered to the max id found in my access database..the problem is it keeps showing the first entry or the entry refered to the min id num...
can anyone help..this is my code to load my page:
Sub Page_Load(sender As Object, e As EventArgs)
label1.text= naharnews().Tables(0).Rows(0)(0)
label2.text= naharnews().Tables(0).Rows(0)(1)
label3.text= naharnews().Tables(0).Rows(0)(2)

databind()
pls, anyone could help!!!!

you can use this sql statement
select top 1 AnyField from table name order by TheIDField Desc

this will return just the first row found at the end of the table
hope its working ;)thanks alot...problem solved...
u're guys amazing
 
Top