473,320 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Write SQL query into Xml

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
3 2254
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: lawrence | last post by:
I've been bad about documentation so far but I'm going to try to be better. I've mostly worked alone so I'm the only one, so far, who's suffered from my bad habits. But I'd like other programmers...
0
by: Tanamon | last post by:
Hello All, I am a MySQL newbie trying to write a query that selects file_name records possessing the highest numbered version for that unique file_name. I show sample data and two trial queries...
7
by: Scott | last post by:
I need help to modify the code below to pass url variables from a framset. The click to run this will be in the mainFrame. This script works well in a non-frame page. Grabs the current url...
2
by: laredotornado | last post by:
Hello, Using PHP 4 and MySQL 4, how would I write a function such that it takes a valid MySQL query, and a column on which to order the query, and return a new query ordered by that column? ...
10
by: sandraz444 | last post by:
I have an expression in the query under my form to autofill the date under a certain condition but it wont write to the underlying table?? The date shows in the form but not the table. Does anyone...
1
by: lorirobn | last post by:
Hi, I have a query that I have been using as a record source for a form with no problems. I just created a new "addnew" form, and added 20 records to the table with this form. The problem I...
2
by: Himmel | last post by:
Hello! The reference database I currently use runs queries that pull data from hundreds of tables in order to create user-friendly form view. The problem is that these queries can take upwards of...
1
by: manikandaprabhu | last post by:
hi all, i am manikandaprabhu. can you help me out in writing the query which should meet the standards and also must have less exection time.how to write a perfect query.And the procedures...
5
by: Jon Skeet [C# MVP] | last post by:
On Sep 9, 9:41 am, raylopez99 <raylope...@yahoo.comwrote: It's tricky in .NET for two reasons: 1) LINQ doesn't have any concept of "remove" 2) List<T>.RemoveAll doesn't pass in the index...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.