Microsoft KB Archive/198533

= PRB: "Class Not Registered" Error Opening an XML Recordset =

Article ID: 198533

Article Last Modified on 5/17/2007

-

APPLIES TO


 * Microsoft ActiveX Data Objects 2.1
 * Microsoft ActiveX Data Objects 2.5
 * Microsoft ActiveX Data Objects 2.6
 * 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 Q198533



SYMPTOMS
Attempting to open an XML recordset in ADO 2.1 may generate the following error:

2147221162 - "Class not registered".

Alternatively, you may see the following error:

Run-time error '3709': The application requested an operation on an object with a reference to a closed or invalid Connection object.



CAUSE
While ADO 2.1 includes libraries that are used to generate AND persist Extensible Markup Language (XML), it does not ship the XML parser required to read the contents of the XML file and generate a recordset object.



RESOLUTION
To download the latest version of MSXML, go to

http://msdn.microsoft.com/xml/default.asp

. You may obtain the Microsoft XML Parser from the following resource:  The XML parser is included with Microsoft Internet Explorer version 5.0. You may download or order Internet Explorer 5.0 from the following Web site:

http://www.microsoft.com/windows/ie/default.mspx

 You may download the Microsoft XML Parser Redistributable, which upgrades the Microsoft XML parser from Internet Explorer 4.01 SP2 or later to the parser provided with Microsoft Internet Explorer 5. The redistributable is available for download from the following site:

http://msdn.microsoft.com/downloads/

NOTE: Although the parser redistributable provides all of the features available from the Microsoft XML parser with Internet Explorer 5, some of the XML features available with Internet Explorer 5 will not work on Internet Explorer 4.01 SP1. The Microsoft Data Access Components versions 2.6 or later include the Microsoft XML Parser. You may download the latest version of the Microsoft Data Access Components from the following site:

http://msdn2.microsoft.com/en-us/data/aa937695.aspx





STATUS
This behavior is by design.



Steps to Reproduce Behavior
The following code persists an ADO recordset to an XML file, then opens the XML file in a second ADO recordset.

This code uses the Pubs database that comes with SQL Server.  In Visual Basic, create a new Standard EXE project. Form1 is created by default.</li> From the Project menu, click References.</li> From the list of References, select the Microsoft ActiveX Data Objects Library.</li> Add two Command buttons to Form1. Command1 and Command2 are created by default.</li>  Paste the following code into the Code window for Form1.

Note You must change User ID and Password to the correct values before you run this code. Make sure that User ID has the appropriate permissions to perform this operation on the database. Private Sub Command1_Click

Dim cn As ADODB.Connection Dim rs As ADODB.Recordset Set cn = New ADODB.Connection Set rs = New ADODB.Recordset

On Error Resume Next Kill "C:\Titles.XML" On Error GoTo 0

cn.Open "Provider=SQLOLEDB;Data Source=(local);" & _ "Initial Catalog=Pubs;User ID= ;Password= ;" rs.Open "select title_id, title from Titles", cn 'Persist the Titles table to an XML file rs.Save "c:\Titles.xml", adPersistXML rs.Close Set rs = Nothing cn.Close Set cn = Nothing End Sub

Private Sub Command2_Click

Dim rsXML As ADODB.Recordset Set rsXML = New ADODB.Recordset 'Open the persisted recordset rsXML.Open "c:\Titles.xml" Do Until rsXML.EOF Debug.Print rsXML(0), rsXML(1) rsXML.MoveNext Loop rsXML.Close Set rsXML = Nothing End Sub

Private Sub Form_Load Command1.Caption = "&Persist" Command2.Caption = "&Retrieve" End Sub </li> Modify the connection string to connect to your server, if necessary.</li> Select Run.</li> Click Persist to persist the Titles table as XML.</li> Click Retrieve to open the XML table.

If the Microsoft XML Parser is not installed, an error occurs on rsXML.Open.</li></ol>

Additional query words: error 2147221162 3709

Keywords: kbprb KB198533

-

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

© Microsoft Corporation. All rights reserved.