Article ID: 326834 - Last Review: August 16, 2002 - Revision: 1.0

FIX: Access Violation Occurs in ADO When You Reopen a Recordset by Using adUseClient and adReadOnly Against MSDASQL

This article was previously published under Q326834

On This Page

Expand all | Collapse all

SYMPTOMS

When you call the Open method of an ADO client-cursor Recordset object that has been opened and closed previously, an access violation may occur if you change the LockType parameter of the method from adLockOptimistic to adLockReadOnly.

This problem only occurs with the Microsoft OLE DB Provider for ODBC (MSDASQL).

RESOLUTION

To resolve this problem, obtain the latest service pack for Microsoft Data Access Components (MDAC) 2.6. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
300635  (http://support.microsoft.com/kb/300635/EN-US/ ) INFO: How to Obtain the Latest MDAC 2.6 Service Pack

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in Microsoft Data Access Components (MDAC) 2.6 Service Pack 2.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a new Standard EXE project in Visual Basic 6.0.
  2. On the Project menu, click References, and then click to select the Microsoft ActiveX Data Objects 2.6 Library check box or the Microsoft ActiveX Data Objects 2.7 Library check box.
  3. Add the following code to the Form_Load event:
    Dim cn As New Connection
    Dim rs As New Recordset
    
    cn.CursorLocation = adUseClient
    cn.Open "Provider=MSDASQL;Driver=SQL Server;server=(local);Trusted_Connection=Yes"
    Set rs.ActiveConnection = cn
    rs.Source = "Select * from sysobjects"
    rs.Open , , adOpenKeyset, adLockOptimistic
    rs.Close
    rs.LockType = adLockReadOnly
    rs.Open          'Access violation occurs here.
    MsgBox "Fixed"   'This message box appears only if you have the fixed version.
    					
  4. Save and then run your project. If you are using Microsoft Data Access Components (MDAC) 2.6 or 2.7, you receive an access violation.

APPLIES TO
  • Microsoft ActiveX Data Objects 2.6
  • Microsoft ActiveX Data Objects 2.7
Keywords: 
kbbug kbclient kbfix KB326834
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
 

Article Translations