把数据保存到XML: 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);把以上代码放到Timer中.
time控制器呢?
不过没想明白为啥不是定时访问数据库呢
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);把以上代码放到Timer中.