XML SQL Server到C# [英] XML SQL Server to C#
本文介绍了XML SQL Server到C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在SQL Server 2005中使用sql创建了XML.我想将该XML保存为文件,放在磁盘上的特定位置.
我只想用C#来完成它.无法使用SQL Server在磁盘上创建该文件,因为我没有Sql Server的管理员权限.
如果我使用DataReader获取字段值,则不会返回完整的xml.
我该怎么办?
I have created an XML using sql in SQL Server 2005. I would like to Save that XML as a File in a particular location on the disk.
I want only C# to make it done. It would not be possible to create that file on the disk using SQL Server because, I don''t have administrator permission for the Sql Server.
If I use DataReader to get field value, than it''s not returning the complete xml.
What do I have to do?
推荐答案
请参见 http://support .microsoft.com/kb/301233 [ ^ ] .
SqlConnection con = new SqlConnection("Data Source=your-pc;Initial catalog=YourDatabase;uid=sa;pwd=*******");
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM YourTable",con);
DataSet ds = new DataSet();
da.Fill(ds);
XmlDocument xml = new XmlDocument();
xml.LoadXml(ds.GetXml());
xml.Save("c:\\test.xml");
谢谢,
马蒙
Thanks,
Mamun
这篇关于XML SQL Server到C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文