INFO: AbsolutePosition Property with JET Databases in ADO

ID: Q194607


The information in this article applies to:
  • ActiveX Data Objects (ADO), versions 1.5, 2.0
  • Microsoft Visual Basic Enterprise Edition for Windows, version 6.0


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://www.microsoft.com/data/download.htm
Alternatively, setting the CursorLocation property of the ADO recordset object to adUseClient corrects this problem.

Steps to Reproduce Behavior

  1. Create a Standard EXE project in Visual Basic. Form1 is created by default.


  2. Add a reference to the Microsoft ActiveX Data Objects Library.


  3. Add a command button to the form and place the following code in the Click event of the button:


  4. 
       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
     
  5. 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.



REFERENCES

For more information about ActiveX Data Objects (ADO) visit the Universal Data Access Web site at the following address:

http://www.microsoft.com/data/

Additional query words:

Keywords : kbADO200 kbADO200bug kbDatabase kbJET kbVBp600 kbGrpVBDB kbGrpMDAC kbDSupport kbADO210sp2fix
Version : WINDOWS:1.5,2.0,6.0
Platform : WINDOWS
Issue type : kbinfo


Last Reviewed: October 21, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.


Send feedback to MSDN.Look here for MSDN Online resources.