熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> ASP編程 >> 正文

根據數據庫生成xml二法

2013-11-15 12:50:57  來源: ASP編程 
SqlConnection conn = new SqlConnection();
      connConnectionString = Server=;User ID=sa;Password=fdahgdrethj;Database=northwind;Persist Security Info=True;
      connOpen();
      SqlDataAdapter da = new SqlDataAdapter(select * from 表 conn);
      SqlCommandBuilder thisBulder = new SqlCommandBuilder(da);
      DataSet ds = new DataSet();
      daFill(ds);
      dsWriteXml(@C:\tempxml);
==============================================================================
private void WriteXmlToFile(DataSet thisDataSet) {
    if (thisDataSet == null) { return; }
    // Create a file name to write to
    string filename = myXmlDocxml;
    // Create the FileStream to write with
    SystemIOFileStream myFileStream = new SystemIOFileStream
       (filename SystemIOFileModeCreate);
    // Create an XmlTextWriter with the fileStream
    SystemXmlXmlTextWriter myXmlWriter =
       new SystemXmlXmlTextWriter(myFileStream SystemTextEncodingUnicode);
    // Write to the file with the WriteXml method
    thisDataSetWriteXml(myXmlWriter);  
    myXmlWriterClose();
}

From:http://tw.wingwit.com/Article/program/ASP/201311/21737.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.