网站首页 > web开发 > 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 }
- 上一篇: 百度新闻开放协议XML文档制作方法简述
- 下一篇: 网页制作关于代码的18个小技巧
猜你喜欢
- 2021-07-16 WAP教程(10):WML参考手册、WML实例和WML DTD-XML/XSLT
- 2021-07-16 WAP教程(11):WAP论坛和开放移动联盟与论坛-XML/XSLT
- 2021-07-16 xml入门教程:XML是什么-XML/XSLT
- 2021-07-16 XML入门教程:XML语法-XML/XSLT
- 2021-07-16 XML入门教程:元素声明-XML/XSLT
- 2021-07-16 XML入门教程:文档类型声明-XML/XSLT
- 2021-07-16 XML入门教程:属性声明-XML/XSLT
- 2021-07-16 XML入门教程:实体-XML/XSLT
- 2021-07-16 XML入门教程:XML名称空间-XML/XSLT
- 2021-07-16 (javascript+asp)XML、XSL转换输出HTML
你 发表评论:
欢迎- 开源分类
- 最近发表
-
- Unity3D研究院之通过ipa或apk获取游戏所使用的unity和Xcode版本
- Unity3D研究院编辑器之脚本生成Preset Libraries(十四)
- 手把手教你Charles抓包工具使用
- python开发的程序内存越来越大_遇到个python进程占用内存太多的问题 | 数据,更懂人心...
- Selenium Python3 请求头配置
- Unity3D研究院之系统内置系统图标大整理
- Unity3D研究院编辑器之5.3JSON的序列化
- Unity3D研究院编辑器之脚本打开SpritePacker窗口(十七)
- #你好Unity3D#Hierarchy视图监听gameObject点击事件
- Unity3D研究院编辑器之自定义默认资源的Inspector面板(十)
- 开源网标签
本文暂时没有评论,来添加一个吧(●'◡'●)