|
|
|
根据数据库生成xml二法 |
|
|
| http://www.iyit.net 日期:2005-11-24 17:31:08 来源:易特网络技术 点击: |
sqlconnection conn = new sqlconnection();
conn.connectionstring = "server=127.0.0.1;user id=sa;password=fdahgdrethj31313210212121;database=northwind;persist security info=true";
conn.open();
sqldataadapter da = new sqldataadapter("select * from 表", conn);
sqlcommandbuilder thisbulder = new sqlcommandbuilder(da);
dataset ds = new dataset();
da.fill(ds);
ds.writexml(@"c:\temp.xml");
==============================================================================
 private void writexmltofile(dataset thisdataset) {
 if (thisdataset == null) { return; }
// create a file name to write to.
string filename = "myxmldoc.xml";
// create the filestream to write with.
system.io.filestream myfilestream = new system.io.filestream
(filename, system.io.filemode.create);
// create an xmltextwriter with the filestream.
system.xml.xmltextwriter myxmlwriter =
new system.xml.xmltextwriter(myfilestream, system.text.encoding.unicode);
// write to the file with the writexml method.
thisdataset.writexml(myxmlwriter);
myxmlwriter.close();
}
|
上一篇:render方法生成静态页
下一篇:asp.net生成静态页
[发送给好友] [打印本页] [关闭窗口] [返回顶部] 转载请注明来源:http://www.iyit.net |
|
| 特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。 |
| 责任编辑: |
投稿作者: 易特网络技术 |
| 信息来源: 易特网络技术 |
录入时间: 2005-11-24 17:31:08 |
| 浏览次数: |
投稿信箱: shtghy@163.com |
|
|
|
|
|