Re: SQL to XML File
- From: "Marc Gravell" <marc.gravell@xxxxxxxxx>
- Date: Mon, 3 Sep 2007 09:53:20 +0100
When you say "the recordset is below that" - what do you mean?
For this scenario, can I just paste some code from a (working)
Click-style event handler?
HttpResponse resp = HttpContext.Current.Response;
resp.Clear();
resp.ContentType = "text/xml"; // or whatever
resp.AddHeader("Content-Disposition",
"attachment;filename=somefile.xml");
using (XmlReader reader = SeeBelow())
using (XmlWriter writer =
XmlWriter.Create(HttpContext.Current.Response.Output))
{
reader.MoveToContent();
writer.WriteNode(reader, false);
writer.Close();
}
resp.End();
where SeeBelow() is something that returns an XmlReader, such as
SqlCommand.ExecuteXmlReader. You can also just use ExecuteReader and
read the character data (either as a single string, or in a char[]
buffer), but the above is fine in most scenarios.
Marc
.
- References:
- SQL to XML File
- From: shank
- SQL to XML File
- Prev by Date: SQL to XML File
- Next by Date: Re: SQL to XML File
- Previous by thread: SQL to XML File
- Next by thread: Re: SQL to XML File
- Index(es):
Relevant Pages
|