国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > XML > 正文

數據庫生成xml的簡單方法

2024-09-05 20:55:25
字體:
來源:轉載
供稿:網友

第一個示例方法:
1 SqlConnection conn = new SqlConnection();
2 conn.ConnectionString = "Server=127.0.0.1;User
ID=sa;Password=fdahgdrethj31313210212121;
Database=northwind;Persist Security Info=True";
3 conn.Open();
4 SqlDataAdapter da = new SqlDataAdapter("select * from 表", conn);
5 SqlCommandBuilder thisBulder = new SqlCommandBuilder(da);
6 DataSet ds = new DataSet();
7 da.Fill(ds);
8 ds.WriteXml(@"C:/temp.xml");
第二個示例方法:
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 }
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 余庆县| 田林县| 江门市| 凤冈县| 会理县| 辉县市| 襄樊市| 扬中市| 棋牌| 皋兰县| 二手房| 连城县| 论坛| 紫金县| 绥中县| 西畴县| 宁明县| 历史| 蒙城县| 雷波县| 阳山县| 安塞县| 嘉善县| 本溪| 武安市| 南投市| 黄石市| 东乡县| 舟山市| 航空| 遂川县| 静宁县| 彰化市| 那坡县| 芦山县| 凤山县| 佛坪县| 天长市| 永靖县| 工布江达县| 镇江市|