FIX: Creating Fabricated Hierarchical Recordset Fails Using MDAC 2.1SP2 (240341)



The information in this article applies to:

  • ActiveX Data Objects (ADO) 2.1 SP2
  • ActiveX Data Objects (ADO) 2.5

This article was previously published under Q240341

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 is the the child recordet,
rsParent is the parent recordset,
ChildCommand is 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

If you are using ADO 2.1 sp2 (build 4202), 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 did not have this problem.

This bug was corrected in Microsoft Data Access Components 2.5 (MDAC 2.5) and later.

You can download the latest version of Microsoft Data Access Components from the following Microsoft Web site:

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 Library.
  3. Double-click Form1 to open Form1's Code Window.
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"
				
Run.

Under MDAC version 2.1 sp2, the error is raised.

REFERENCES

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

231943 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:

196029 HOWTO: Create Hierarchical Recordsets Programmatically


Modification Type:MinorLast Reviewed:4/22/2003
Keywords:kbADO250Fix kbbug kbfix kbMDAC250fix kbMDACNoSweep KB240341