国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 远安县| 靖江市| 鱼台县| 冀州市| 华池县| 余江县| 西盟| 蓬溪县| 南城县| 双峰县| 和田县| 正蓝旗| 桓仁| 高密市| 孟村| 常山县| 安平县| 保亭| 呼和浩特市| 南雄市| 咸丰县| 台南市| 商丘市| 盐城市| 东丰县| 新昌县| 安达市| 白银市| 宾阳县| 泗水县| 南昌县| 兰坪| 永春县| 南康市| 双柏县| 西安市| 南川市| 太原市| 沾化县| 镇巴县| 旅游|