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.WriteXml(@"C:\temp.XML");
==================================================

private void WriteXMLToFile(DataSet thisDataSet)
{
if (thisDataSet == null)
{ return; }
// Create a file name to write to.
string filename = "myXmlDoc.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 myXMLWriter =
new System.Xml.XMLTextWriter(myFileStream, System.Text.Encoding.Unicode);
// Write to the file with the WriteXML method.
thisDataSet.WriteXml(myXMLWriter);
myXMLWriter.Close();
}