時(shí)間:2015/6/28來(lái)源:IT貓撲網(wǎng)作者:網(wǎng)管聯(lián)盟我要評(píng)論(0)
第一個(gè)示例方法:
1 SqlConnection conn = new SqlConnection();
2 conn.ConnectionString = "Server=127.0.0.1;User
ID=sa;Password=fdahgdrethj31313210212121;
Database=northwind;Persist Security Info=True";
3 conn.Open();
4 SqlDataAdapter da = new SqlDataAdapter("select * from 表", conn);
5 SqlCommandBuilder thisBulder = new SqlCommandBuilder(da);
6 DataSet ds = new DataSet();
7 da.Fill(ds);
8 ds.WriteXML(@"C:\temp.xml");
第二個(gè)示例方法:
1 private void WriteXmlToFile(DataSet thisDataSet)
2 {
3 if (thisDataSet == null) { return; }
4 // Create a file name to write to.
5 string filename = "myXmlDoc.xml";
6 // Create the FileStream to write with.
7 System.IO.FileStream myFileStream = new System.IO.FileStream
8 (filename, System.IO.FileMode.Create);
9 // Create an XmlTextWriter with the fileStream.
10 System.Xml.XmlTextWriter myXmlWriter =
11 new System.Xml.XmlTextWriter
(myFileStream, System.Text.Encoding.Unicode);
12 // Write to the file with the WriteXml method.
13 thisDataSet.WriteXml(myXmlWriter);
14 myXmlWriter.Close();
15 }
關(guān)鍵詞標(biāo)簽:數(shù)據(jù)庫(kù),xml
相關(guān)閱讀
熱門(mén)文章 Active Server Pages 錯(cuò)誤 'ASP 0131'解決方
人氣排行 ASP下標(biāo)越界的解決方法ASP代碼中如何屏蔽ip地址 禁止某IP段訪問(wèn)網(wǎng)站“文件共享鎖定數(shù)溢出” 原因及解決方法無(wú)法寫(xiě)入數(shù)據(jù)庫(kù)的解決方法如何用ASP來(lái)獲取客戶端真實(shí)IP的地址用Asp編程實(shí)現(xiàn)QQ的在線情況查詢ASP常用函數(shù)列表ASP用FSO生成HTML簡(jiǎn)單實(shí)例+詳解[原創(chuàng)]