Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO - first record and last record only

Status
Not open for further replies.

onressy

Programmer
Mar 7, 2006
421
CA
after a record set is created is there an ADO record set parameter that one can use to get the last record value from a column as well as the first. i only need the First value and the last.

If i try to select the firts record and then use
objRS.MoveLast i get an error of: Rowset does not support fetching backward.

Do i really have to do two seperate queries?

Thanks
 
No you can fiddle around with the recordset properties like CursorLocation, CursorType, and LockType.

The default recordset properties give you a forward-only "Firehose" cursor.
 
To extend that thought from Sheco: a static recordset (as opposed to forward-only, dynamic, or keyset) will let you read the first and then use MoveLast to hit the end record. The reason a Forward-only can't do a last is because it doesn't even know how many records it is holding. It strictly exists for you to ooop forward with MoveNext's.
Another option would be to use the GetRows method of the recordset object to dump the entire recordset into an 2-dimensional array. At which point you could access the data in any order and multiple times. This is probably overkill for what your currently trying to do though.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top