Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Enterprise
Expertise: Beginner
Feb 1, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Quickly Convert Recordset into an XML File

With MDAC 2.1 (Microsoft Data Access Components), you can generate a XML file quickly from a Recordset object.

The Save() method of Recordset object takes in an optional parameter, adPersistXML, of type "PersistFormatEnum." By specifying adPersistXML in the Save() method, you can save the Recordset object into a file in XML format. Similarly, you can reopen a Recordset by providing a previously saved XML file.

Here is an example that saves a Recordset as an XML file:

 Public Sub GenerateXML()
   Dim oRecordset As ADODB.Recordset
   ' Create Recordset object
   Set oRecordset = CreateObject("ADODB.Recordset")
   ' Open Recordset
   oRecordset.Open "SELECT * FROM MyTable", _
      "DSN=Sample;Provider=MSDASQL; uid=sa;pwd=;", _
      adOpenDynamic, adLockOptimistic, adCmdText
   ' Save Recordset as an XML file
   oRecordset.Save "C:\MyFolder\MyTable.xml", adPersistXML
   ' Close Recordset
End Sub
Deepak Pant
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date