FIX: ADO Client Cursor Engine Leaks Memory If Provider Does Not Support Some DBPROP or Rowset Properties (322149)



The information in this article applies to:

  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.6
  • Microsoft Data Access Components 2.7
  • ActiveX Data Objects (ADO) 2.5
  • ActiveX Data Objects (ADO) 2.6
  • ActiveX Data Objects (ADO) 2.7

This article was previously published under Q322149

SYMPTOMS

The ADO Client Cursor Engine may leak memory when you use it with a custom, third-party OLE DB provider. The leak occurs if the custom provider does not support some common OLE DB properties in the DPROPSET_DATASOURCEINFO and DBPROPSET_ROWSET property sets, including the following properties:
  • DBPROP_DBMSNAME
  • DBPROP_MULTIPLERESULTS
  • DBPROP_PROVIDERNAME
  • DBPROP_SCHEMATERM
  • DBPROP_COMMANDTIMEOUT
  • DBPROP_USERNAME
  • DBPROP_IRowsetChange
  • DBPROP_IRowsetUpdate
If custom providers return DB_E_ERRORSOCCURRED when the ADO Client Cursor Engine calls the IRowsetInfo::GetProperties or the IDBProperties::GetProperties method for these properties, the ADO Client Cursor Engine leaks memory.

This problem does not occur if the GetProperties call succeeds. Therefore, the ADO Client Cursor Engine may leak memory if all of the following conditions are true:
  • Your custom provider does not support any of the properties that are listed earlier in this section.
  • Your custom provider returns DB_E_ERRORSOCCURRED when the ADO Client Cursor Engine calls IRowsetInfo::GetProperties or IDBProperties::GetProperties.

CAUSE

The "IRowsetInfo::GetProperties" and the "IDBProperties::GetProperties" topics of the OLE DB specification state that if the provider returns DB_E_ERRORSOCCURRED for a particular property, the client should free these properties. The ADO Client Cursor Engine does not release this memory for some properties.

RESOLUTION

To resolve this problem, obtain the latest service pack for Microsoft SQL Server 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack

MDAC 2.7

The English version of this fix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
   Date         Version       Size     File name     Platform
   -----------------------------------------------------------
   May-13-2002  2.70.8713.0   307,200  Msadce.dll    x86
				

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 SQL Server 2000 Service Pack 3.

MORE INFORMATION

If your provider does not support all of the properties that are listed in the "Symptoms" section of this article, you can use the following code to reproduce the leak:
Private Sub Command1_Click()
    For i = 1 To 10
        Test
    Next
    MsgBox "Done"
End Sub

Sub Test()
    Dim cn As String
    Dim query As String
    Dim connection As New ADODB.connection
    Dim rs As ADODB.Recordset
    Set rs = CreateObject("ADODB.Recordset")

    cn = "Provider=YOURPROVIDER;UID=YourUID;PWD=YourPassword"
    query = "Select * FROM AnyTable"
        rs.CursorLocation = adUseClient
        connection.Open cn        
        For i = 1 To 1000
          rs.Open query, connection, adOpenDynamic, adLockPessimistic
          rs.Close
        Next
        connection.Close
End Sub
				

Modification Type:MinorLast Reviewed:9/27/2005
Keywords:kbHotfixServer kbQFE kbSQLServ2000sp3fix kbbug kbfix kbSQLServ2000preSP3fix KB322149