Microsoft KB Archive/194607

= INFO: AbsolutePosition Property with JET Databases in ADO =

Article ID: 194607

Article Last Modified on 5/17/2007

-

APPLIES TO


 * Microsoft ActiveX Data Objects 1.5
 * Microsoft ActiveX Data Objects 2.0
 * Microsoft ActiveX Data Objects 2.5
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q194607



SUMMARY
The AbsolutePosition Property in ADO returns a -1 if the Cursorlocation property is set to adUseServer, the ADO default. This is essentially saying that the AbsolutePosition is unknown, adPositionUnknown.

This behavior occurs using the Microsoft Jet OLE DB Provider 3.51.



MORE INFORMATION
Setting the CursorLocation property of the ADO recordset object to adUseClient corrects this problem.

Using the Microsoft Jet OLE DB Provider 4.0 and later, the AbsolutePosition is returned correctly.

The Microsoft Jet OLE DB Provider 4.0 and later are available in the latest download of the Microsoft Data Access Components, version 2.1 Service Pack 2 and later.

The Microsoft Data Access Components are available for download from the following site:

http://msdn2.microsoft.com/en-us/data/aa937695.aspx

Alternatively, setting the CursorLocation property of the ADO recordset object to adUseClient corrects this problem.

Steps to Reproduce Behavior
 Create a Standard EXE project in Visual Basic. Form1 is created by default. Add a reference to the Microsoft ActiveX Data Objects Library.  Add a command button to the form and place the following code in the Click event of the button: Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset

cn.Open "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security " & _ "Info=False;Data Source=C:\Program Files\Microsoft Visual " & _ "Studio\VB98\Nwind.mdb"

'Uncomment the lines below, and comment the lines above, 'to test with Jet OLE DB 4.0, 'cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security " & _ '"Info=False;Data Source=C:\Program Files\Microsoft Visual " & _ '"Studio\VB98\Nwind.mdb"

'Or uncomment the below line to get the correct AbsolutePosition 'value rs.CursorLocation = adUseClient. rs.Open "select * from employees", cn, adOpenKeyset

Debug.Print "There are " & rs.RecordCount & " records in employees"

Debug.Print "AbsolutePosition is " & rs.AbsolutePosition

 Run the code to test the project. Using the Microsoft Jet OLE DB Provider 3.51, note that the AbsolutePosition property returns -1 (adPositionUnknown) when the CursorLocation is set to server. Using the Microsoft Jet OLE DB Provider 4.0 or later, or using a client-side cursor, the AbsolutePosition property correctly returns 1.

