By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,775 Members | 1,345 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,775 IT Pros & Developers. It's quick & easy.

Write SQL query into Xml

P: n/a
Hi,

In my C# windows form project, I would like to have a function which will
write the SQL query result into an XML file.
Would someone tell me how to do this?
Thanks for help.
Jason
Apr 3 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Check the XMLDocument class out.. System.XML.XMLDocument. That should help
you

Vijay

"Jason Huang" <Ja************@hotmail.com> wrote in message
news:OS**************@TK2MSFTNGP09.phx.gbl...
Hi,

In my C# windows form project, I would like to have a function which will
write the SQL query result into an XML file.
Would someone tell me how to do this?
Thanks for help.
Jason

Apr 3 '06 #2

P: n/a
Jason,

If you are using SQL Server 2005, check out the FOR XML syntax for your
query. It will allow the results to be returned as XML. You can then use
the ExecuteXmlReader method on the SqlConnection class to get an XmlReader
you can use to read XML from the query.

Additionally, for any data back end, you can just populate a dataset,
then call the WriteXml method to write the data set to a stream in XML
format. You can then transform or use it any way you like.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jason Huang" <Ja************@hotmail.com> wrote in message
news:OS**************@TK2MSFTNGP09.phx.gbl...
Hi,

In my C# windows form project, I would like to have a function which will
write the SQL query result into an XML file.
Would someone tell me how to do this?
Thanks for help.
Jason

Apr 3 '06 #3

P: n/a
Hello Jason,

If you works with DataSet/DataTable just call .WriteXml method

JH> In my C# windows form project, I would like to have a function which
JH> will
JH> write the SQL query result into an XML file.
JH> Would someone tell me how to do this?
JH> Thanks for help.
JH> Jason

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Apr 3 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.