473,386 Members | 1,908 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,386 software developers and data experts.

Save DB query results as XML file

I am trying to query a SQL Server database, retrieve the results as XML, and
save them to a file. I was trying to use the SqlXmlCommand,
SqlXmlCommandType.XPath and an xsd to query the database, and load the
results into a XmlTextReader. This works fine. But then I get stuck. I
don't want to DO anything with the data besides putting it into a file.
Should I be loading the results into a stream, instead? Then load the stream
into a string, to an XmlDocument, then .Save(...)? Or might a XmlTextWriter
have a role in here somewhere?

Can anyone give me a hint on how I should approach this?
Nov 12 '05 #1
1 1519
Trillium wrote:
I am trying to query a SQL Server database, retrieve the results as XML, and
save them to a file. I was trying to use the SqlXmlCommand,
SqlXmlCommandType.XPath and an xsd to query the database, and load the
results into a XmlTextReader. This works fine. But then I get stuck. I
don't want to DO anything with the data besides putting it into a file.
Should I be loading the results into a stream, instead? Then load the stream
into a string, to an XmlDocument, then .Save(...)? Or might a XmlTextWriter
have a role in here somewhere?

Can anyone give me a hint on how I should approach this?


XmlTextWriter w = new XmlTextWriter(file, encoding);
while (reader.Read())
w.WriteNode(r, false);
w.Close();
r.Close();
--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: sumGirl | last post by:
Can someone demonstrate a SIMPLE way to do this that does not require additional functions or stored procedures to be created? Lets say I want to execute the following simple query - "select * from...
1
by: DraguVaso | last post by:
Hi, I found some examples for storing the FormSettings of a Form in an XML-file, but none of these could match my criteria: What I am looking for is the possibility to save the FormSettings of...
5
by: Carl | last post by:
Please can anyone tell me how I can create a macro to save the results of a query as an excel file? The query is called Student List and I would like to save it to "My Documents". We have had...
1
by: J. Koskey | last post by:
Background: We have hundreds of codes = specific departments, but there are frequent changes/additions to the info. For users to look up definitions, we had set up a way in Access to create a...
0
by: Rob | last post by:
I doubt this is the best way to do it, but what I came up with was to hide the XML in an HTML Comment then edit the file deleting the HTML stuff and keep the XML results. If anyone has a better...
4
by: Nikhil Tayal | last post by:
Is there a way to write a file on the client machine from an aspx page? I've a custom query page and need to store the search criteria specified in an XML file on the user machine from my web page...
3
by: ferd | last post by:
Hello, I want to query an access database in ASP (classic) and save the results as an XML file that I can use as a Data Island in Internet Explorer - I have the recordset, I can save it as XML,...
2
by: nuhura01 | last post by:
Hi.. I'm trying to save query path which is in text box to text file. Below is the coding that i'm using currently: Private Sub SaveQueryPath() 'save to text file Response.Clear()...
6
scubak1w1
by: scubak1w1 | last post by:
Hello, I have been Googling for a bit now as to how to let the user save the current page via a 'clickable icon' to an HTML file (i.e., on the client side.) That is, I am presenting a lot of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.