BUG: ADO Client Cursors Report LockType = adLockPessimistic

ID: Q190625

The information in this article applies to:

SYMPTOMS

ActiveX Data Objects (ADO) incorrectly reports that a client-side recordset opened with a LockType of adLockPessimistic was opened with pessimistic locking.

The ADO client cursor engine does not support pessimistic locking. If you ask ADO for a pessimistically locked client-side recordset, you actually receive an optimistically locked recordset instead, even though ADO did not change the value of the LockType property to adLockOptimistic.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Behavior

1. Open a Standard.exe project in Visual Basic, and add a reference to the

   Microsoft ActiveX Data Object Library.

2. Copy and paste the following code into the form code window:

      Option Explicit
      Dim myconn As New ADODB.Connection
      Dim myrs As New ADODB.Recordset


      Private Sub Form_Load()
        Dim strConn As String

        'Modify the connection string to point to your NWind.MDB file.
         strConn = "Provider=MSDASQL;" & _
              "Driver={Microsoft Access Driver (*.mdb)};" & _
              "DBQ=D:\vb5\Labs\LAB10\NWind.MDB"

        myconn.CursorLocation = adUseClient
         myconn.Open strConn

       'Request a pessimistically locked cursor.
       'ADO's client cursor engine only supports optimistic locking.
         myrs.Open "SELECT * FROM Customers", myconn, _
              adOpenStatic, adLockPessimistic, adCmdText
         MsgBox "MyRS.LockType = " & myrs.LockType & vbCrLf & _
                "adLockPessimistic = " & adLockPessimistic & vbCrLf & _
                "adLockOptimistic = " & adLockOptimistic
         myrs.Close

3. Run the form and note the output of the message boxes.

REFERENCES

ADO 2.0 documentation.

Additional query words: kbADO150bug kbADO200bug kbado200

Version           : WINDOWS:1.5,2.0,5.0,6.0
Platform          : WINDOWS
Issue type        : kbbug
Solution Type     : kbpending

Last Reviewed: August 7, 1998