VBA/Excel/Access/Word/Access/Recordset to XML — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 16:33, 26 мая 2010
Creating an XML Document from ADO
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
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