导出数据:
-----------------------------------------------
DataSet ds = new DataSet();
SqlConnection conn = new SqlConnection("server = localhost;uid=sa;pwd=1qaz2wsx;database=test");
conn.Open();
SqlCommand comm = null;
comm = new SqlCommand(@"SELECT * FROM person",conn);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = comm;
da.Fill(ds,"table");
ds.WirteXml(@"C://a.xml",XmWriteMode.WriteSchema);
-------------------------------------------------------
恢复数据:
DataSet dsEx = new DataSet();
dsEx.ReadXml(@"c://a.xml",XmlReadMode.ReadSchema);
foreach (DataRow d2r in ds.Tables["table"].Rows)
{
d2r.Delete();
}
da.Update(ds,"table");
ds = dsEx.Copy();
da.Update(ds,"table");
来源:博远电子(软件定制),如涉及版权问题请与我们联系。
TAG
软件定制,软件开发,瀚森HANSEN,辽宁,沈阳,抚顺