PRB: "Class not registered" Error Opening an XML Recordset
ID: Q198533
|
The information in this article applies to:
-
ActiveX Data Objects (ADO), versions 2.1, 2.1 SP2
-
Microsoft Visual Basic Professional and Enterprise Editions for Windows, versions 5.0, 6.0
-
Microsoft Visual Studio versions 6.0, 97
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
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.htm
Alternatively, 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/tools/xmlparser/xmldl.asp
Note that 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.
STATUS
This behavior is by design.
MORE INFORMATION
STEPS TO REPRODUCE
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.
- Set a Project | Reference to the Microsoft ActiveX Data Objects Library.
- Add two Command buttons to Form1. Command1 and Command2 are created by default.
- Paste the following code into the Code window for Form1.
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=sa;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
- Modify the connection string to connect to your server, if necessary.
- Select Run.
- Click Persist to persist the Titles table as XML.
- Click Retrieve to open the XML table.
If Internet Explorer 5 or the Microsoft XML redistributable are not installed, an error occurs on rsXML.Open.
Additional query words:
Keywords : kbADO210 kbDatabase kbVBp500 kbVBp600 kbXML kbGrpVBDB kbGrpMDAC kbDSupport kbADO210sp2
Version : WINDOWS:2.1,2.1 SP2,5.0,6.0,97
Platform : WINDOWS
Issue type : kbprb