FIX: Access Violation Passing ADO Command Object to ADO Recordset Open() with MDAC 2.6 (301199)



The information in this article applies to:

  • Microsoft Data Access Components 2.6
  • Microsoft Data Access Components 2.6 SP1
  • ActiveX Data Objects (ADO) 2.6

This article was previously published under Q301199

SYMPTOMS

When you pass an ActiveX Data Objects (ADO) Command object to the ADO Recordset.Open method, an access violation in Msado15.dll may occur.

RESOLUTION

This problem has been corrected in MDAC 2.6 Service Pack 2 (SP2) and MDAC 2.7. If you cannot upgrade to these versions, a hotfix is also available.

For additional information about MDAC 2.6 SP2, click the article number below to view the article in the Microsoft Knowledge Base:

300635 INFO: How to Obtain the Latest MDAC 2.6 Service Pack

The English version of this fix should have the following file attributes or later:
 Date         Version       Size     File name     Platform
 -----------------------------------------------------------
 25-JUN-2001  2.61.7625.0   528,656  Msado15.dll   x86
				

WORKAROUND

To work around this problem, do not pass a Command object to the Open method of a Recordset object.

STATUS

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

MORE INFORMATION

To reproduce the problem, run the following Microsoft Visual Basic for Applications (VBA) code:
Sub MergePropSetCrash()
Dim conn As ADODB.Connection
Dim cmd As ADODB.Command
Dim rs As ADODB.recordset

    Set conn = New ADODB.Connection
    conn.Open "Provider=MSDASQL;Driver={SQL Server};" & _
        "Server=.;Database=Pubs;TrustedConnection=Yes;"
    
    Set cmd = New ADODB.Command
    Set cmd.ActiveConnection = conn
    
    cmd.CommandType = adCmdText
    
    cmd.CommandText = "select 1"
    cmd.Execute
    
    Set rs = New ADODB.recordset
    rs.CursorLocation = adUseClient
    cmd.CommandText = "select 2"
    rs.Open cmd, , adOpenKeyset, adLockOptimistic, adCmdText

End Sub
				
An attached debugger or crash dump displays a call stack that resembles the following:
Access violation - code c0000005 (first chance)
eax=00e46608 ebx=00e45fcc ecx=00680a82 
edx=01a03400 esi=00e46bbc edi=00e47000
eip=1f48883d esp=0012fa04 ebp=0012fa34 iopl=0 nv up ei pl nz na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00010206
msado15!MergePropSets+1dd:
1f48883d f3a5            rep  movsd ds:00e46bbc=00000000 es:00e47000=????????
0:000> kv
RetAddr  Args to Child              
1f487ce3 0012fa68 0012fa6c 00e45f98 msado15!MergePropSets+0x1dd
1f486c47 00001000 00000000 00000001 msado15!CQuery__SetProperties+0x215
1f453eb4 00000003 0042b700 00000000 msado15!CQuery__Execute+0x700 
1f45b655 00e43700 00000003 0042b700 msado15!CCommand___Execute+0x18a
1f45aea4 00000001 0042b700 0012fe18 msado15!CRecordset___Open+0x236
0041ae65 00e44a00 cccc0009 cccccccc msado15!CRecordset__Open+0x5ea 
				

Modification Type:MinorLast Reviewed:9/26/2005
Keywords:kbHotfixServer kbQFE kbbug kbmdac260sp2fix KB301199 kbAudDeveloper