设为首页
加入收藏
站点地图
首页 | 网站建设 | 杭州FPGA培训班,浙江FPGA培训班,苏州FPGA培训班,昆山FPGA培训班,常州FPGA培训班优化 | 网站推广 | 网络营销 | 网站运营 | 网站策划 | 在线讨论 | 下载中心
您当前的位置:WebSite -> 网站建设 -> 文章内容正文->数据库自动生成xml的方法
 子栏目导航
 热门文章
 相关文章
 

数据库自动生成xml的方法

作者:Somnus  来源:转载  发布时间:2008-8-11 9:51:20  

第一个示例方法:

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 }

 [返回上一页] [打 印] [收 藏]
百度中查看“数据库自动生成xml的方法”相关文章

版权申明:本站网站建设资源来源网络,如有侵犯您的版权,请来Q告知 我们会在24小时内删除!

Copyright © 2008-2010 www.mepeixun.com All Rights Reserved
服务QQ:52466268 邮箱:meipeixun@163.com
备案号:苏ICP备07200130号