Displaying ADO Retrieved Data with XML Islands - Extracting XML formatted data example
(Page 2 of 7 )
Using the save() method of ADO, you could save the recordset to a file as shown in the next paragraph. The recordset is created by accessing an MDB file on the hard drive. Not all the columns in the 'Employees' table in the Northwind database will be saved as an XML file. The variable fileName points to the location on the hard drive where the XML file will be saved.

Create UI to test code
On a form in your MS Access application add a button, and to the click event of this button add the following code. The statement
rs.save fileName, adPersistXML >
can also be saved as
rs.save fileName2, adPersistADTG
where fileName2 will have an .adtg extension. This is yet another proprietary format called the Advanced Data TableGram format. We will only look at the persisted XML formatted file.
Private Sub Command0_Click()
Dim rs As New ADODB.Recordset
fileName = "C:NwindEmployees.xml"
rs.Open "Select * from Employees where LastName='Peacock'", _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:Documents and SettingsJayMy DocumentsRetrieve.mdb;" & _
"Persist Security Info=False", adOpenKeyset, adLockOptimistic,
adCmdText
If Dir$(fileName) <> "" Then Kill fileName
rs.Save fileName, adPersistXML
End Sub
In the above code the recordset for the indicated SQL statement will be saved.
Next: The Saved XML file >>
More XML Articles
More By Jayaram Krishnaswamy