by Yuening Dai (30 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 12th March 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Save ADO Recordset data in XML format file
'
'Modified from Microsoft KB sample.
'You need to have ADO 2.1 installed on your machine and set reference to it first.
'
Dim Rst1 As New ADODB.Recordset
Dim Rst2 As New ADODB.Recordset
'
Rst1.Fields.Append "xx1", adInteger
Rst1.Fields.Append "xx2", adChar, 5
Rst1.Fields.Refresh
'
'Add something to it. Have to open it first.
Rst1.Open
Rst1.AddNew
Rst1.Fields(0).Value = 1
Rst1.Fields(1).Value = "NAME1"
Rst1.Update
'
Kill "C:\Recordset.XML"
'
'Persist data in Recordset to an XML file
Rst1.Save "c:\Recordset.xml", adPersistXML
Rst1.Close
Set Rst1 = Nothing
'
'Read XML file data into Recordset.
Rst2.Open "c:\Recordset.xml"
Do Until Rst2.EOF
Debug.Print Rst2(0), Rst2(1)
Rst2.MoveNext
Loop
'
Rst2.Close
Set Rst2 = Nothing
'
'If you have IE5 on your machine, you can use it to open this xml file.
'
End Sub