FIX: Creating Fabricated Hierarchical Recordset Fails Using MDAC 2.1SP2

ID: Q240341


The information in this article applies to:
  • ActiveX Data Objects (ADO), versions 2.1 SP2, 2.5


SYMPTOMS

When trying to create a fabricated (programmatic) hierarchical recordset using MDAC 2.1 SP2 (build 4202), the following error is generated:

Run-Time error '-2147467259 (80004005)': Unspecified error
This error occurs on the line that sets the child recordset to the child chaptered command. This line of code might look like:

Set rsChild = rsParent("ChildCommand").Value
  
where:


rsChild    : child recordet,
rsParent   : parent recordset,
ChildCommand    : the child chaptered command. 


CAUSE

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.


RESOLUTION

There is a workaround for this bug; simply add a line of code that sets the ActiveConnection of the parent recordset to Nothing. Your code might look like this:


.........

Set rsParent.ActiveConnection = Nothing   
Set rsChild = rsParent.Fields("ChildCommand").Value

......... 


STATUS

Previous releases of MDAC 2.1 SP2 did not have this problem. This bug was corrected in Microsoft Data Access Components 2.5 (MDAC 2.5).


MORE INFORMATION

Steps to Reproduce Behavior

  1. Start a new project in Visual Basic and select Standard EXE. Form1 is created by default.


  2. At the Visual Basic project, reference the following object library: Microsoft ActiveX Data Objects 2.5 Library.


  3. Double-click Form1.Copy and paste the following code under the Form_Load() event:



Dim RS As New Recordset
Dim SubRS As Recordset
       
RS.LockType = adLockBatchOptimistic
RS.Open "SHAPE APPEND NEW adInteger as RecordID, " + _
                 "NEW adVarchar(20) as RecordData, " + _
                 "((SHAPE APPEND NEW adInteger as RecordID, " + _
                                "NEW adVarchar(20) as SubRecordData" + _
                 ") Relate RecordID to RecordID) as SubRecord", _
                 "Provider=MSDataShape;Data Provider=None"
       
RS.AddNew
RS!RecordID = 1
RS!RecordData = "Test Record Data"
Set SubRS = RS!SubRecord.Value  ' Error occurs here
SubRS.AddNew
SubRS!RecordID = 1
SubRS!SubRecordData = "Test Subrecord Data"
SubRS.AddNew
SubRS!RecordID = 2
SubRS!SubRecordData = "Another Subrecord" 


REFERENCES

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

Q231943 INFO: Microsoft Data Access Components (MDAC) Release History
For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
Q196029 HOWTO: Create Hierarchical Recordsets Programmatically

© Microsoft Corporation 1999, All Rights Reserved.
Contributions by Hussein Abuthuraya, Microsoft Corporation

Additional query words: kbado250fix

Keywords : kbMDAC kbGrpVBDB kbGrpMDAC kbDSupport kbADO210sp2bug kbMDAC210SP2bug kbMDAC250fix
Version : WINDOWS:2.1 SP2,2.5
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: December 30, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.