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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADODB Database

Status
Not open for further replies.

Qamgine

Programmer
Mar 6, 2001
126
US
Is there anyway to retrieve the current record position of an ADODB recordset? When I use an ADODC control on the form I can say:

Label1.Caption = ADODC.Recordset.AbsolutePosition

and it will return the current record it's on. When I use a design time database ADODB.Recordset the AbsolutePosition never changes from -1. ex:
------------
Dim adoConn as New ADODB.Connection, rs as ADODB.Recordset
Dim ConnString as String, SQLString as string
ConnString = "Provider=MSDASQL.1;Persist Security Info=False;Extended Properties=" & Chr(34) & "DBQ=c:\PhysTrack.mdb;DefaultDir=C:\;Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;FILEDSN=c:\phystrack.dsn;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;" & Chr(34)

SQLString = "Select * From Doctor"

adoConn.Open ConnString
rs.Open SQLString, adoConn, adOpenStatic, adLockBatchOptimistic, (adCmdText + adAsyncFetchNonBlocking)
if rs.EOF = False then
Label1.Caption = rs.AbsolutePosition
end if
rs.close
adoconn.close
set rs = nothing
set adoconn = nothing
---------

I always get -1 as my absolute position. I've tried movefirst, movelast, etc. I don't want to have to have a variable and increment to keep track of what record I'm on. A bit tedious. Any help on this would be greatly appreciated!
 
try

rs.Open SQLString, adoConn, adOpenKeySet, adLockBatchOptimistic, (adCmdText + adAsyncFetchNonBlocking)

the absolute position and paging functions only work for certain types of recordset.
 
try

rs.Open SQLString, adoConn, adOpenKeySet, adLockBatchOptimistic, (adCmdText + adAsyncFetchNonBlocking)

the absolute position and paging functions only work for certain types of recordset."

Tried and still doesn't work. :(
 
This could be a provider problem i.e "MSDASQL.1", it mightnt be implement the required interface IRowsetLocate and as such you wont be able to get the "AbsolutePosition" data back.
Microsoft also recommends that you use bookmarks to get current record position rather than absoluteposition.

The other i notice is that your code will either return 1 as you dont seem to do anything with the recordset after opening it?

"Own only what you can carry with you; know language, know countries, know people. Let your memory be your travel bag.
 
The other i notice is that your code will either return 1 as you dont seem to do anything with the recordset after opening it? "

It was an example not true code. :)

Thanks for the heads up will try using bookmarks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top