国产探花免费观看_亚洲丰满少妇自慰呻吟_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 }
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 邓州市| 凤山市| 桐乡市| 修武县| 固阳县| 平武县| 新昌县| 灵石县| 宜阳县| 尚义县| 洪泽县| 衡水市| 山西省| 成武县| 开化县| 静宁县| 江西省| 邵阳市| 花莲县| 栾城县| 宜丰县| 安丘市| 旬阳县| 阿拉善右旗| 九寨沟县| 安多县| 阿荣旗| 武陟县| 桐庐县| 娄烦县| 嘉黎县| 建瓯市| 五台县| 惠来县| 喀什市| 洪泽县| 阜平县| 吉安县| 东阿县| 应用必备| 丰原市|