Click to See Complete Forum and Search --> : pls help
deulu
05-04-2005, 03:46 AM
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!!!!
A1ien51
05-04-2005, 12:53 PM
what is your sql statement?
deulu
05-05-2005, 12:41 AM
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...
A1ien51
05-05-2005, 09:07 PM
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.....
Eric
MikeFlyer
05-07-2005, 01:48 AM
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!!!!
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 ;)
deulu
05-08-2005, 09:40 AM
thanks alot...problem solved...
u're guys amazing