Save the recordset as an XML file : Recordset to XML « Access « VBA / Excel / Access / Word






Save the recordset as an XML file

 
Sub SaveRst_ToXMLwithADO() 
    Dim myRecordset As ADODB.Recordset 
    Dim conn As New ADODB.Connection 
    Const strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & CurrentProject.Path & "\mydb.mdb"
    conn.Open strConn 
    Set myRecordset = conn.Execute("SELECT * FROM Products") 
    On Error Resume Next 
    Kill "C:\yourFile.xml" 
    myRecordset.Save "C:\yourFile.xml", adPersistXML 
    Set myRecordset = Nothing 
    Set conn = Nothing 
End Sub 

 








Related examples in the same category

1.Creating an XML Document from ADO