首 页站长学院免费论文实用文书客户留言繁體中文
设为首页
加入收藏
联系我们
您当前的位置:爱上范文网 -> 站长学院 -> 网站编程 -> NET教程 -> 文章内容 退出登录 用户管理
栏目导航
· ASP教程 · PHP教程
· JSP教程 · NET教程
· XML教程 · CGI教程
热门文章
· [组图] 2006:浏览器进入多元...
· 个人SMTP服务器的配...
· 不可忽视的BIOS参数...
· 趣话电脑病毒19年发...
· 什么是FTP及什么是F...
· [组图] Frontpage2000实务高...
· [图文] 网络协议X档案全集(...
· 局域网优化的六大秘...
· [组图] 新建Photoshop图像
· [组图] 用FrontPage 2000下...
相关文章
根据数据库生成xml二法
作者:无从考证  来源:中国软件  发布时间:2005-8-23 20:17:53  发布人:admin

减小字体 增大字体

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();
 }

[] [返回上一页] [打 印] [收 藏]
上一篇文章:Render方法生成静态页
下一篇文章:asp.net生成静态页
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 管理登录
Copyright © 2002-2005 23fw.com. All Rights Reserved .