Most optimised way to get data from SQL server and write xml?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi All,
I want to ask quite a general question. I am looking for the prefered approach to query a database and write its results to an xml file. I have managed this but as the xml file is quite big (30mb but will get bigger) this process takes quite a while (several
minutes) and I just wanted to see if there was some silver bullet that I was not awre of.
Currently I use as datareader to populate and then typically use this sort of approach:
<pre style="font-family:Consolas; background:white; color:black; font-size:13px <pre style="font-family:Consolas; background:white; color:black; font-size:13px <span style="color:blue while (reader.Read())
{
<span style="color:blue string date = reader.GetString(0);
_writer.WriteElementString(<span style="color:#a31515 "DATE", date);
_writer.WriteEndElement();
}[/code]
[/code]
But obviously iterating like this will take time. Is there any way to improve the preformance of this?
Thanks, Dave.

View the full article
 
Back
Top