zoukankan      html  css  js  c++  java
  • 根据数据库生成xml二法

    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();
    }
  • 相关阅读:
    importToMbtiles
    http-server服务跨域设置
    Leaflet 测试加载高德地图
    矢量切片
    zigzag方式编码
    CentOS7安装docker
    CentOS7安装NodeJS
    CentOS7上Python3.5安装
    JDK8下maven使用maven-javadoc-plugin插件报错
    Ubuntu16.10上安装NodeJS6.9.2
  • 原文地址:https://www.cnblogs.com/cuihongyu3503319/p/607705.html
Copyright © 2011-2022 走看看