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

首頁 > 開發(fā) > XML > 正文

數(shù)據(jù)庫生成xml的簡單方法

2024-09-05 20:56:09
字體:
供稿:網(wǎng)友

第一個示例方法:
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 }
上一篇:XML模式:vCard

下一篇:XML模式:RDF

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 永年县| 屏东市| 通榆县| 佛山市| 罗源县| 五河县| 彩票| 阳江市| 河津市| 印江| 庄河市| 望城县| 丰城市| 威远县| 吴堡县| 姚安县| 通江县| 仪陇县| 临清市| 崇仁县| 新源县| 简阳市| 米脂县| 莆田市| 丹江口市| 法库县| 儋州市| 阿拉尔市| 陈巴尔虎旗| 舟山市| 乐业县| 平罗县| 石林| 阿尔山市| 涪陵区| 进贤县| 高台县| 永吉县| 林西县| 全椒县| 云阳县|