动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   .Net → 阅读文章

 根据数据库生成xml二法

作者:无从考证 来源:中国软件 
阅读 1809 人次 , 2006-2-15 14:26:00 

SqlConnection conn = new SqlConnection();
      conn.ConnectionString 
= "Server=127.0.0.1;User ID=sa;Password=fdahgdrethj31313210212121;Database=northwind;Persist Security Info=True";
      conn.Open();
      SqlDataAdapter da 
= new SqlDataAdapter("select * from 表", conn);
      SqlCommandBuilder thisBulder 
= new SqlCommandBuilder(da);
      DataSet ds 
= new DataSet();
      da.Fill(ds);
      ds.WriteXml(
@"C:\temp.xml");
==============================================================================
private void WriteXmlToFile(DataSet thisDataSet) {
    
if (thisDataSet == nullreturn; }
    
// Create a file name to write to.
    string filename = "myXmlDoc.xml";
    
// Create the FileStream to write with.
    System.IO.FileStream myFileStream = new System.IO.FileStream
       (filename, System.IO.FileMode.Create);
    
// Create an XmlTextWriter with the fileStream.
    System.Xml.XmlTextWriter myXmlWriter = 
       
new System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
    
// Write to the file with the WriteXml method.
    thisDataSet.WriteXml(myXmlWriter);   
    myXmlWriter.Close();
 }
  
 本文Tags数据库  
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:asp.net生成静态页
· 下一篇:Render方法生成静态页
· 从ASP迁移至ASP+ --处理会话变量(Session Variables) 
· 在ASP.NET中使用.NET组件
· 10天学会ASP.net之第八天
· C#正则表达式应用范例
· Resin 1.2 重要源代码暴露漏洞


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077