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

MSSQL
黑客经验谈 MSSQL SA权限入侵的感悟
3个步骤结束网站恶梦-SQL注入隐患!
用人工智能自动对SQL语句进行重写
防范sql注入式攻击js版本
SQL Server 2005数据库镜像配置脚本示例
SQL Server和Oracle的真正区别
如何把Access的数据导入到Mysql中
看看自己掌握了多少SQL快捷键
SQL2005数据库转到SQL2000的步骤
SQL“多字段模糊匹配关键字查询”
高手是怎样炼成的:精妙SQL语句介绍
SQL Server 2000数据库崩溃后的补救措施
SQL Server日志清除的两种方法教程简介
教你快速掌握数据库设计范式的基本概念
远程连接SQL Server 2000服务器的解决方案
循序渐进讲解数据表的十二个设计原则
经验总结:讲解大型数据库的设计准则
开发环境下优化SQl语句的十个重要步骤
如何查看并导出数据表中字段的注释信息
SQL Server 2005改进后的几个实用新特性

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


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