INFO: AbsolutePosition Property with JET Databases in ADO (194607)



The information in this article applies to:

  • ActiveX Data Objects (ADO) 1.5
  • ActiveX Data Objects (ADO) 2.0
  • ActiveX Data Objects (ADO) 2.5
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0

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

Modification Type:MinorLast Reviewed:3/14/2005
Keywords:kbADO210sp2fix kbBug kbDatabase kbinfo kbJET kbMDACNoSweep KB194607