日期:2008-07-13  浏览次数:20398 次

Write relational data to an XML file
Submitted ByUser LevelDate of Submission
Mahesh ChandBeginner03/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.