将sql表转换为xml文件 [英] conversion sql table to xml file
本文介绍了将sql表转换为xml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
i希望将sql server 2008表转换为xml file.please发给我详细信息。
提前谢谢
hi
i want to convert sql server 2008 table convert to xml file.please send me details.
advance thanks
推荐答案
您好,
请参阅以下示例。它会对你有所帮助。
http://blog.sqlauthority.com/2009/02/12/sql-server-simple-example-of-creating-xml-file-using- t-sql / [ ^ ]
谢谢,
Viprat
Hi,
See the below examples. It will help you.
http://blog.sqlauthority.com/2009/02/12/sql-server-simple-example-of-creating-xml-file-using-t-sql/[^]
Thanks,
Viprat
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constring"].ConnectionString);
if (con.State == ConnectionState.Closed)
{
con.Open();
}
SqlCommand cmd = new SqlCommand("select name ,user_code from tbl_user ", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
ds.Tables[0].WriteXml(@"D:\text.xml");
if (con.State == ConnectionState.Open)
{
con.Close();
}
数据集具有WriteXml方法以满足您的需求。填充数据集并使用该方法。 King_fisher示例将起作用。
Dataset have WriteXml method to serve your purpose. Fill your dataset and use that method. King_fisher example will work.
这篇关于将sql表转换为xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文