web前端

位置:IT落伍者 >> web前端 >> 浏览文章

根据数据库生成xml二法


发布日期:2019年01月31日
 
根据数据库生成xml二法
SqlConnection conn = new SqlConnection();

connConnectionString = Server=;User ID=sa;Password=fdahgdrethj;Database=northwind;Persist Security Info=True;

connOpen();

SqlDataAdapter da = new SqlDataAdapter(select * from 表 conn);

SqlCommandBuilder thisBulder = new SqlCommandBuilder(da);

DataSet ds = new DataSet();

daFill(ds);

dsWriteXml(@C:\tempxml);

==============================================================================

private void WriteXmlToFile(DataSet thisDataSet) {

if (thisDataSet == null) { return; }

// Create a file name to write to

string filename = myXmlDocxml;

// Create the FileStream to write with

SystemIOFileStream myFileStream = new SystemIOFileStream

(filename SystemIOFileModeCreate);

// Create an XmlTextWriter with the fileStream

SystemXmlXmlTextWriter myXmlWriter =

new SystemXmlXmlTextWriter(myFileStream SystemTextEncodingUnicode);

// Write to the file with the WriteXml method

thisDataSetWriteXml(myXmlWriter);

myXmlWriterClose();

}

上一篇:带你认识Eclipse XML编辑器

下一篇:使用XML为列表控件绑定数据