1. 程式人生 > >C#中DataTable轉換為string

C#中DataTable轉換為string

DataTable dt = new DataTable();
DataSet ds = new DataSet();
ds.Tables.Add(dt);
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter(sw);
ds.WriteXml(xm)
string s = sw.ToString();