數(shù)據庫生成xml的兩個方法
來源:易賢網 閱讀:906 次 日期:2014-11-17 14:25:50
溫馨提示:易賢網小編為您整理了“數(shù)據庫生成xml的兩個方法”,方便廣大網友查閱!

第一個示例方法:

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 }

更多信息請查看IT技術專欄

更多信息請查看數(shù)據庫
易賢網手機網站地址:數(shù)據庫生成xml的兩個方法
關于我們 | 聯(lián)系我們 | 人才招聘 | 網站聲明 | 網站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權所有:易賢網