Microsoft KB Archive/312085

= FIX: When You Disconnect a Hierarchical Recordset the Connection Is Not Released =

Article ID: 312085

Article Last Modified on 10/12/2005

-

APPLIES TO


 * Microsoft Data Access Components 2.6

-



This article was previously published under Q312085



SYMPTOMS
When you disconnect a recordset that is returned from the Microsoft DataShape provider, it may appear that the recordset is disconnected. However, when the active connections are examined, the connection is still open. In some circumstances this may use up all of the available connections. The errors that are returned depend on the type of database server that the application connects to.



RESOLUTION
There are workarounds available for this problem that are discussed in the &quot;Workarounds&quot; section.

NOTE: The fix described only addresses the problem if the following criteria are met:
 * The recordset was not created with a parameterized query.
 * The recordset does not have to be reconnected later to perform an update.
 * The code that uses the recordsets can be modified as described in the &quot;Enable a Full Disconnect&quot; section later in this article.

A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Microsoft Data Access Components that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

NOTE: In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The typical support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

The English version of this fix should have the following file attributes or later:

MDAC 2.6 Service Pack 1 File name   Size     Date        Version -  Msadce.dll   336,144  07-Nov-2001   2.62.8106.0 Msadcer.dll 20,480   07-Nov-2001   2.62.8106.0 Msadcf.dll  65,808   07-Nov-2001   2.62.8106.0 Msadcfr.dll 12,288   07-Nov-2001   2.62.8106.0 Msadco.dll  147,728  07-Nov-2001   2.62.8106.0 Msadcor.dll 16,384   07-Nov-2001   2.62.8106.0 Msadcs.dll  57,616   07-Nov-2001   2.62.8106.0 Msadds.dll  168,208  07-Nov-2001   2.62.8106.0 Msaddsr.dll 24,576   07-Nov-2001   2.62.8106.0 Msdaprsr.dll 16,384  07-Nov-2001   2.62.8106.0 Msdaprst.dll 209,168 07-Nov-2001   2.62.8106.0 Msdarem.dll 123,152  07-Nov-2001   2.62.8106.0 Msdaremr.dll 16,384  07-Nov-2001   2.62.8106.0 Msdfmap.dll 37,136   07-Nov-2001   2.62.8106.0 MDAC 2.7 File name   Size     Date        Version -  Msadce.dll  307,200   06-26-2002    2.70.9001.7 Msadcf.dll 57,344    06-26-2002    2.70.9001.7 Msadco.dll 131,072   06-26-2002    2.70.9001.7 Msadcs.dll 53,248    06-26-2002    2.70.9001.7 Msadds.dll 147,456   06-26-2002    2.70.9001.7 Msadaprst.dll 180,224  6-26-2002   2.70.9001.7 Msadarem.dll 110,592   6-26-2002   2.70.9001.7 Msadfmap.dll 32,768  06-26-2002    2.70.9001.7

Enable a Full Disconnect
After you apply the fix, you must enable the fix to properly use it. To to this, follow these steps:.   Before you open the recordset, set its cursor location explicitly to client, and then set the following new property on the recordset: rs.CursorLocation = adUseClient rs.Properties(&quot;Release Shape On Disconnect&quot;) = True ' new property   If your returned recordset is truly hierarchical (for example, it has child chapters), the ActiveConnection property of each of these must be set to Nothing (Visual Basic) or null (Java), or what is appropriate for the language that is used. This is simplified by using a recursive function such as the following: DisconnectAll rs Where DisconnectAll is defined as follows: Private Function DisconnectAll(rs As ADODB.Recordset) Dim i As Long With rs  Set .ActiveConnection = Nothing For i = 0 To rs.Fields.Count - 1 If (rs.Fields(i).Type = adChapter) Then DisconnectAll rs.Fields(i).Value End If  Next i End With End Function



Workarounds
If you have to create a series of disconnected recordsets from the same data source, the same connection object can be reused to create the second, the third, and any subsequent recordsets even when you disconnect the first recordset, and that connection remains open. This approach provides a solution without applying the fix that is described in this article.

There are alternative workarounds to this problem that may be more convenient and easier to use that are discussed in the following Knowledge Base article:

288409 Disconnected Hierarchical Recordset Does Not Disconnect from Database Server



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
If the MSDataShape provider is used to obtain a series of disconnected recordsets from an Oracle server in the scope of a COM+ transaction, you may receive the following error message:

Data provider could not be initialized

If you examine the Oracle trace files (TRC) you may see the following error message:

ORACLE XA: Version 8.1.7.0.0. RM name = 'Oracle_XA'.

112639.3284:2528.2528.11: ORA-02045: too many local sessions participating in global transaction

112639.3284:2528.2528.11: xaostart: OCITransStart rtn 2045, too many branches in transaction

Even though it seems that each recordset is disconnected when you set the ActiveConnection property to Nothing or null, the connection is not released. The next recordset that is made creates a new session in the same global transaction of the Oracle server. At the time of this writing, Oracle supports up to eight sessions in a single global transaction by default.

