I've got a few tables that I want to select records out of and put into an XML file. Each table will have its own node tree with it's records underneath. Is there a "good" way to do this besides doing it manually (looping thru datareaders and stuff like that). I've tried using the XmlReader/DataSet.WriteXml() and only get one record. I'm using a SQL Server query with FOR XML AUTO, ELEMENTS appended to it. Any help would be greatly appreciated.
Todd 8 1542
What about using the Dataset and it's methods to create the XML?
"Todd Bright" <To********@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com... I've got a few tables that I want to select records out of and put into an
XML file. Each table will have its own node tree with it's records
underneath. Is there a "good" way to do this besides doing it manually
(looping thru datareaders and stuff like that). I've tried using the
XmlReader/DataSet.WriteXml() and only get one record. I'm using a SQL
Server query with FOR XML AUTO, ELEMENTS appended to it. Any help would be
greatly appreciated. Todd
Have you looked at the managed SQLXML classes http://msdn.microsoft.com/library/de...otnet_0jck.asp ?
"Jim Douglas" wrote: What about using the Dataset and it's methods to create the XML?
"Todd Bright" <To********@discussions.microsoft.com> wrote in message news:CE**********************************@microsof t.com... I've got a few tables that I want to select records out of and put into an XML file. Each table will have its own node tree with it's records underneath. Is there a "good" way to do this besides doing it manually (looping thru datareaders and stuff like that). I've tried using the XmlReader/DataSet.WriteXml() and only get one record. I'm using a SQL Server query with FOR XML AUTO, ELEMENTS appended to it. Any help would be greatly appreciated. Todd
Todd Bright wrote: I've got a few tables that I want to select records out of and put into an XML file. Each table will have its own node tree with it's records underneath. Is there a "good" way to do this besides doing it manually (looping thru datareaders and stuff like that). I've tried using the XmlReader/DataSet.WriteXml() and only get one record. I'm using a SQL Server query with FOR XML AUTO, ELEMENTS appended to it. Any help would be greatly appreciated.
Todd
This is easy as pie.
Instead of doing an ExecuteReader on your SqlCommand, do an ExecuteXMLReader
and it loads it into an XML file.
XMLReader xr = myCmd.ExcecuteXMLReader();
Take the resultant ( xr ) and create an XML Document with it.
XMLDocument xd = new XMLDocument(xr);
Then do a xd.Save("<filename>") name on the Document.
--
w:4
Tried this one too. It only gives me one record back, unless I do a read for each record. And as far as I can tell, there's no way to tell how many records there are.
"Benjamin Disraeli" wrote: Todd Bright wrote:
I've got a few tables that I want to select records out of and put into an XML file. Each table will have its own node tree with it's records underneath. Is there a "good" way to do this besides doing it manually (looping thru datareaders and stuff like that). I've tried using the XmlReader/DataSet.WriteXml() and only get one record. I'm using a SQL Server query with FOR XML AUTO, ELEMENTS appended to it. Any help would be greatly appreciated.
Todd
This is easy as pie.
Instead of doing an ExecuteReader on your SqlCommand, do an ExecuteXMLReader and it loads it into an XML file.
XMLReader xr = myCmd.ExcecuteXMLReader();
Take the resultant ( xr ) and create an XML Document with it.
XMLDocument xd = new XMLDocument(xr);
Then do a xd.Save("<filename>") name on the Document.
-- w:4
According to the docs, SQLXML is able to be used if VS .Net is installed? Yet the IDE will still not show me the System.Data.SqlXml class? Guess I'm just gonna have to do this manually.
"Niroo" wrote: Have you looked at the managed SQLXML classes http://msdn.microsoft.com/library/de...otnet_0jck.asp ?
"Jim Douglas" wrote:
What about using the Dataset and it's methods to create the XML?
"Todd Bright" <To********@discussions.microsoft.com> wrote in message news:CE**********************************@microsof t.com... I've got a few tables that I want to select records out of and put into an XML file. Each table will have its own node tree with it's records underneath. Is there a "good" way to do this besides doing it manually (looping thru datareaders and stuff like that). I've tried using the XmlReader/DataSet.WriteXml() and only get one record. I'm using a SQL Server query with FOR XML AUTO, ELEMENTS appended to it. Any help would be greatly appreciated. Todd
I made a mistake... one of the examples references using Microsoft.Data.SqlXml. But intellisense doesn't show a Data class under the Microsoft class???
"Todd Bright" wrote: According to the docs, SQLXML is able to be used if VS .Net is installed? Yet the IDE will still not show me the System.Data.SqlXml class? Guess I'm just gonna have to do this manually.
"Niroo" wrote:
Have you looked at the managed SQLXML classes http://msdn.microsoft.com/library/de...otnet_0jck.asp ?
"Jim Douglas" wrote:
What about using the Dataset and it's methods to create the XML?
"Todd Bright" <To********@discussions.microsoft.com> wrote in message news:CE**********************************@microsof t.com... > I've got a few tables that I want to select records out of and put into an XML file. Each table will have its own node tree with it's records underneath. Is there a "good" way to do this besides doing it manually (looping thru datareaders and stuff like that). I've tried using the XmlReader/DataSet.WriteXml() and only get one record. I'm using a SQL Server query with FOR XML AUTO, ELEMENTS appended to it. Any help would be greatly appreciated. > > Todd
Todd Bright wrote:
Left off a step: http://www.dbforums.com/t698233.html
strTmp = xmlReader.ReadOuterXml()
While strTmp.Length > 0
sbBuilder.Append(strTmp)
strTmp = xmlReader.ReadOuterXml()
End While
sbBuilder.Append("")
xmlReader.Close()
xmlReturn.LoadXml(sbBuilder.ToString()) Tried this one too. It only gives me one record back, unless I do a read for each record. And as far as I can tell, there's no way to tell how many records there are.
"Benjamin Disraeli" wrote:
Todd Bright wrote:
> I've got a few tables that I want to select records out of and put into > an > XML file. Each table will have its own node tree with it's records > underneath. Is there a "good" way to do this besides doing it manually > (looping thru datareaders and stuff like that). I've tried using the > XmlReader/DataSet.WriteXml() and only get one record. I'm using a SQL > Server query with FOR XML AUTO, ELEMENTS appended to it. Any help > would be greatly appreciated. > > Todd
This is easy as pie.
Instead of doing an ExecuteReader on your SqlCommand, do an ExecuteXMLReader and it loads it into an XML file.
XMLReader xr = myCmd.ExcecuteXMLReader();
Take the resultant ( xr ) and create an XML Document with it.
XMLDocument xd = new XMLDocument(xr);
Then do a xd.Save("<filename>") name on the Document.
-- w:4
--
w:4
I'll have to bookmark this one.
I ended up just looping thru the recordset manually and using the XmlTextWriter object. MUCH more straightforward than the XmlReader. I spent half a day investigating different ways to execute a SQL statement back and put into an XML file, none of which worked the way I was looking for. Took me maybe an hour to investigate the XmlTextWriter and write the code to implement it.
"William Ewart Gladstone" wrote: Todd Bright wrote:
Left off a step:
http://www.dbforums.com/t698233.html
strTmp = xmlReader.ReadOuterXml() While strTmp.Length > 0 sbBuilder.Append(strTmp) strTmp = xmlReader.ReadOuterXml() End While sbBuilder.Append("")
xmlReader.Close() xmlReturn.LoadXml(sbBuilder.ToString())
Tried this one too. It only gives me one record back, unless I do a read for each record. And as far as I can tell, there's no way to tell how many records there are.
"Benjamin Disraeli" wrote:
Todd Bright wrote:
> I've got a few tables that I want to select records out of and put into > an > XML file. Each table will have its own node tree with it's records > underneath. Is there a "good" way to do this besides doing it manually > (looping thru datareaders and stuff like that). I've tried using the > XmlReader/DataSet.WriteXml() and only get one record. I'm using a SQL > Server query with FOR XML AUTO, ELEMENTS appended to it. Any help > would be greatly appreciated. > > Todd
This is easy as pie.
Instead of doing an ExecuteReader on your SqlCommand, do an ExecuteXMLReader and it loads it into an XML file.
XMLReader xr = myCmd.ExcecuteXMLReader();
Take the resultant ( xr ) and create an XML Document with it.
XMLDocument xd = new XMLDocument(xr);
Then do a xd.Save("<filename>") name on the Document.
-- w:4
-- w:4
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mudge |
last post by:
Please, someone, tell me why OO in PHP is better than procedural.
|
by: Max M |
last post by:
Yesterday there was an article on Slashdot:
http://books.slashdot.org/article.pl?sid=03/09/04/1415210&mode=flat&tid=108&tid=126&tid=156
It is about automatic code generation.
I got interrested...
|
by: Rasmus Fogh |
last post by:
Someone raised the question of automatic code generation a few weeks back.
And yes, we (CCPN) are using automatic Python code generation in a major
way. Basically we are making data models in...
|
by: |
last post by:
Wel, I am rebuilding the VC# 2002 project that I have deployment problems
with the 2003 version, hoping this solves the problems, but now I encounter
this wierd bug???
If I have the project, and...
|
by: Hayato Iriumi |
last post by:
Hello,
I hear some hypes about creating code to generate C# or VB .NET code, that
is, code generation (sounds straight forward enough). I haven't really seen
how it's done in real world. I'm...
|
by: George Meng |
last post by:
I want to evaluate some code generation tool for my company. Want to get
some idea from you.
The bottom line is I want to get a tool to generate both store procedure as
well as business object...
|
by: Eddy Ilg |
last post by:
Hi,
I would like to suppress .pyc generation or have the .pyc generation in a
speical seperate root (I found something about PYCROOT). Has this been
implemented yet? Is there an environment...
|
by: eliben |
last post by:
Hello,
In a Python program I'm writing I need to dynamically generate
functions and store them in a dict. eval() can't work for me
because a function definition is a statement and not an...
|
by: Troels Arvin |
last post by:
Hello,
We have started planning our DB2 generation 8 -9.1/9.5 upgrades, as
April 30 2009 is no longer distant future (ordinary support for DB2
generation 8 on Linux/Unix/Windows==LUW will end on...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
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....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |