IT貓撲網(wǎng):您身邊最放心的安全下載站! 最新更新|軟件分類|軟件專題|手機版|論壇轉(zhuǎn)貼|軟件發(fā)布

您當前所在位置:首頁網(wǎng)絡編程Asp編程 → 數(shù)據(jù)庫生成xml的兩個方法

數(shù)據(jù)庫生成xml的兩個方法

時間:2015/6/28來源:IT貓撲網(wǎng)作者:網(wǎng)管聯(lián)盟我要評論(0)

第一個示例方法:

  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");

第二個示例方法:

  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 }

關鍵詞標簽:數(shù)據(jù)庫,xml

相關閱讀

文章評論
發(fā)表評論

熱門文章 Active Server Pages 錯誤 'ASP 0131'解決方Active Server Pages 錯誤 'ASP 0131'解決方

相關下載

人氣排行 ASP下標越界的解決方法ASP代碼中如何屏蔽ip地址 禁止某IP段訪問網(wǎng)站“文件共享鎖定數(shù)溢出” 原因及解決方法無法寫入數(shù)據(jù)庫的解決方法如何用ASP來獲取客戶端真實IP的地址用Asp編程實現(xiàn)QQ的在線情況查詢ASP常用函數(shù)列表ASP用FSO生成HTML簡單實例+詳解[原創(chuàng)]