SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Server=127.0.0.1;User ID=sa;Password=fdahgdrethj31313210212121;Database=northwind;Persist Security Info=True";
conn.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from 表", conn);
SqlCommandBuilder thisBulder = new SqlCommandBuilder(da);
DataSet ds = new DataSet();
da.Fill(ds);
ds.Write
xml(@"C:temp.
xml");
==============================================================================
private void Write
xmlToFile(DataSet thisDataSet) {
if (thisDataSet == null) { return; }
// Create a file name to write to.
string filename = "my
xmlDoc.
xml";
// Create the FileStream to write with.
System.IO.FileStream myFileStream = new System.IO.FileStream
(filename, System.IO.FileMode.Create);
// Create an
xmlTextWriter with the fileStream.
System.
xml.
xmlTextWriter my
xmlWriter =
new System.
xml.
xmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
// Write to the file with the Write
xml method.
thisDataSet.Write
xml(my
xmlWriter);
my
xmlWriter.Close();
}