Microsoft KB Archive/283164

= PRB: Error Message When MSXML DOMDocument Is Loaded by Supplying an ADO 2.5 Stream Object =

Article ID: 283164

Article Last Modified on 3/7/2003

-

APPLIES TO


 * Microsoft XML Parser 2.0
 * Microsoft XML Parser 2.5
 * Microsoft XML Parser 2.6
 * Microsoft XML Core Services 4.0
 * Microsoft XML Parser 3.0 Service Pack 1
 * Microsoft XML Core Services 4.0
 * Microsoft ActiveX Data Objects 2.5
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q283164



SYMPTOMS
If you attempt to run the Load method of an MSXML DOMDocument object by supplying an ActiveX Data Object (ADO) 2.5 Stream object that contains valid XML data as the xmlSource parameter, the following error message is generated:

Run-time error '5': Invalid procedure call or argument



CAUSE
A string that specifies the path of the XML file to be loaded, or a Component Object Model (COM) object that is queryable for the IStream interface can be supplied as the xmlSource parameter when you run the Load method of the DOMDocument object. The ADO 2.5 Stream object is not internally queryable for the IStream interface.



RESOLUTION
There are two possible solutions to the problem:
 * If you upgrade to MDAC 2.6, the problem does not occur when you supply an ADO 2.6 Stream object as the xmlSource parameter for the Load method of an MSXML DOMDocument object. The ADO 2.6 Stream object is internally queryable for the IStream interface. -or-


 * If you cannot upgrade to MDAC 2.6, the ReadText method of the ADO 2.5 Stream object returns the contents of an adTypeText Stream object as a string. Run the loadXML method of the MSXML DOMDocument and supply the string returned by running the ReadText method of the Stream object as the bstrXML parameter.



STATUS
This problem has been fixed in MDAC 2.6. The Implementation of the ADO 2.6 Stream object has been modified to make it internally queryable for the IStream interface.

For more information, see the MDAC pages on the following Microsoft Web site at:

http://msdn.microsoft.com/dataaccess



MORE INFORMATION
If a newer version of MSXML has been installed in side-by-side mode, you must explicitly use the Globally Unique Identifiers (GUIDs) or ProgIDs for that version to run the sample code. For example, MSXML version 4.0 can only be installed in side-by-side mode. For additional information about the code changes that are required to run the sample code with the MSXML 4.0 parser, click the following article number to view the article in the Microsoft Knowledge Base:

305019 INFO: MSXML 4.0 Specific GUIDs and ProgIds

Steps to Reproduce Behavior
NOTE: This Visual Basic sample references version 3.0 of the MSXML parser. You can reference a prior version of the MSXML parser in your Visual Basic project if you have not installed version 3.0.

The installation of MDAC 2.6 replaces the core ADO DLL (msado15.dll) that implements the ADO Stream object. Therefore, the problem cannot be reproduced by referencing the ActiveX Data Objects 2.5 type library (msado25.tlb) after you install MDAC 2.6.

Follow the steps that are listed here to reproduce the problem that is specified in the &quot;Symptoms&quot; section of this article:  Open a new Standard EXE project in Visual Basic. Form1 is created by default. On the Project menu, choose References, and then set references to Microsoft ActiveX Data Objects 2.5 Library and Microsoft XML, v3.0. Add a CommandButton to Form1.  Copy and paste the following code in the Click event procedure of the CommandButton: Dim xmldoc As MSXML2.DOMDocument30 Dim strm As ADODB.Stream

Set strm = New ADODB.Stream strm.Type = adTypeText strm.Charset = &quot;ascii&quot; strm.Open strm.WriteText &quot;XML Programming&quot; strm.Position = 0

'Change the ProgID of the DOMDocument object in the following statement 'as required if you are referencing an older version of the MSXML parser. Set xmldoc = New MSXML2.DOMDocument30

xmldoc.Load strm Debug.Print xmldoc.xml </li> Save and run the project.</li> Click the CommandButton when the form is displayed, and note that the xmldoc.Load statement generates the error specified in the &quot;Symptoms&quot; section of this article.</li> Stop the project by clicking End.</li>  Replace the xmldoc.Load statement with the following line of code, and then save the project: xmldoc.loadXML strm.ReadText </li> When you run the project and click the CommandButton on the form that is displayed, note that the error does not occur. The XML data that is loaded into the DOMDocument object by supplying the ADO stream object as the xmlSource parameter is written out to the Visual Basic Debug window.</li></ol>

Additional query words: 5

Keywords: kbprb KB283164

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.