Microsoft KB Archive/326834

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

Article ID: 326834

Article Last Modified on 8/16/2002

-

APPLIES TO


 * Microsoft ActiveX Data Objects 2.6
 * Microsoft ActiveX Data Objects 2.7

-



This article was previously published under Q326834



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



Steps to Reproduce the Behavior
 Create a new Standard EXE project in Visual Basic 6.0. 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.  Add the following code to the Form_Load event: Dim cn As New Connection Dim rs As New Recordset

cn.CursorLocation = adUseClient cn.Open &quot;Provider=MSDASQL;Driver=SQL Server;server=(local);Trusted_Connection=Yes&quot; Set rs.ActiveConnection = cn rs.Source = &quot;Select * from sysobjects&quot; rs.Open, , adOpenKeyset, adLockOptimistic rs.Close rs.LockType = adLockReadOnly rs.Open         'Access violation occurs here. MsgBox &quot;Fixed&quot;  'This message box appears only if you have the fixed version.  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.

Additional query words: Crash AV Assert client-side Read-only Kagera

Keywords: kbbug kbfix kbclient KB326834

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.