当前位置: 首页 > 图文教程 > 数据库 > MSSQL > 带你轻松接触数据库生成xml的两个方法

MSSQL
在SQL Server下数据库链接的使用
SQL Server数据库中处理空值时常见问题
巧用一条SQL语句实现其它进制到十进制转换
通过JDBC连接DB2数据库技巧
深入浅出SQL教程之嵌套SELECT语句
SQL Server备份文件中导入现存数据库
SQL多表格查询合并至单一声明的常用方式
也谈如何缩小SQL SERVER日志文件
四个语句帮你提高 SQL Server 的伸缩性
用JavaBean编写SQL Server数据库连接类
sql2k中新增加的Function的sqlbook 的帮助
Mssql处理孤立用户的存储过程
探讨SQL Server中Case 的不同用法
快速清除SQLServer日志的两种方法
解决Sql Server警报的疑难问题
MySQL的数据类型和建库策略
SQL SERVER应用问题解答13例(一)
SQL SERVER应用问题解答13例(二)
多种还原.bak数据库文件方式
SQL语句中的一些特殊参数如何用变量来代替

MSSQL 中的 带你轻松接触数据库生成xml的两个方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-17   浏览: 89 ::
收藏到网摘: n/a

第一个示例方法:

第二个示例方法:

以下为引用的内容:

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 }