gettting last record from DB
Hey,
I'm just wondering how to get the last record of the db, I try the following and get an error....
strconn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="
accessdb = server.mappath("../db/portalDB.mdb")
strconn=strconn & accessdb & ";"
query2 = "SELECT * from test"
set db = server.CreateObject("adodb.connection")
db.open strconn
set rs = db.execute(query2)
rs.movelast 'line 33
rs.moveprevious
lastid = rs("ID")
response.write (lastid)
And I get the following error...
Microsoft JET Database Engine (0x80040E24)
Rowset does not support fetching backward.
/portal/Carnet/ajouter.asp, line 33
Right now I have a crappy work around that works, that I just itterate through the whole db, but that has a bit of an overhead...
rs.movefirst
while not rs.eof
lastid = rs("ID")
rs.movenext
wend
response.write (lastid)
Any help would be great..
|