Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
Posted
Updated 12-Jun-11 21:05pm
v2

 
Share this answer
 
C#
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900