| Write relational data to an XML file |
| Submitted By | User Level | Date of Submission |
| Mahesh Chand | Beginner | 03/15/2001 |
The DataSet class can be used to read a relational database table and write this table to an XML file. You use WriteXMLData or WriteXml class to write a DataSet data to an XML file.
In this sample example, I have used access 2000 database, mydb.mdb. This database has a table, myTable.
| ADODataSetCommand adoCmd = new ADODataSetCommand( "SELECT * FROM myTable", "Provider=Microsoft.JET.OLEDB.4.0;data source=mydb.mdb" ); DataSet ds = new DataSet(); adoCmd.FillDataSet(ds,"myTable"); ds.WriteXmlData("reldata.xml"); |
WriteXmlData method takes one parameter and that is XML file name which stores the data from the database.
