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

MSSQL
SQL Server 数据库操作实用技巧锦集
SQL Server转换为XQuery及反向转换
SQL Server 数据库崩溃后的恢复之法
在 SQL Server数据库开发中的十大问题
SQL Server 2000日志转移实现高可用性
帮你六步改善SQL Server安全规划全攻略
教你如何在SQL Server计算机列和平均值
理解 SQL Server 中系统表Sysobjects
用实例分析如何整理SQL Server输入数据
让VB实现SQL Server 2000存储过程调用
利用OBJECT_DEFINITION函数来代码存档
DTS构建组件及其如何完成数据转换服务
编写SQL Server的扩展存储过程实例
SQL Server和Oracle并行处理方法对比
SQL Server数据转换服务基本概念介绍
如何由Sybase向SQL Server移植数据库
如何在SQL Server中由原子建立分子查询
SQL Server用触发器强制执行业务规则
SQL Server数据库导入MySQL数据库体验
SQL Server可写脚本和编程扩展SSIS包

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-17   浏览: 140 ::
收藏到网摘: 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 }