Forum Moderators: open

Message Too Old, No Replies

Last record in Table - How to get there?

         

powerslave

10:25 am on May 8, 2005 (gmt 0)

10+ Year Member



I was wondering the best way to get the recordset to the last set of records in a table

I have tried recordset.Movelast and it showed nothing

so i then tried .movelast then .moveprevious and that still showed nothing.

Only one that worked for me was a while loop going through them all, is this the only way to reach it?

Thanks

mattglet

12:13 pm on May 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not totally sure of your needs, but here's one method:

SELECT TOP 1 whatever FROM yourtable ORDER BY somethingSortable DESC

mrMister

6:03 pm on May 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



powerslave, you're using the wrong cursor type for your recordset.

Try creating your recordset like this...

Set objRecordset = Server.CreateObject("ADODB.Recordset")
Set objRecordset.ActiveConnection = YourConnectionString
objRecordset.CursorLocation = 3 'adUseClient
objRecordset.CursorType = 2 'adOpenDynamic

powerslave

1:14 pm on May 9, 2005 (gmt 0)

10+ Year Member



So what does

objRecordset.CursorLocation = 3 'adUseClient
objRecordset.CursorType = 2 'adOpenDynamic

Do?

hard for me to understand if i dont understand the theory...i notice when some people open recordsets they use numbers as well after them, I dont get what that means either.

Ill add those lines in and see if they change anything

Thanks

mrMister

2:02 pm on May 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So what does
objRecordset.CursorLocation = 3 'adUseClient
objRecordset.CursorType = 2 'adOpenDynamic

Do?

Cursor Location [msdn.microsoft.com]

Cursor Type [msdn.microsoft.com]