Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sql query result to xml

Status
Not open for further replies.

rwaldron

MIS
Aug 6, 2002
53
IE
Hi all,
I am trying to produce an XML to a web service from the result of an sql query..I am very close with below but when I run the asp.net page I get a blank page.
Can someone help me.
Do I need to use a dataset?
Query does return data in sql.
I want the final result to produce htt:\\localhost\file.xml

Thx..Ray..

Code below




Dim sConnection As String = ("****MyConnectionString****")
Dim mySqlConnection As SqlConnection = New SqlConnection(sConnection)


mySqlConnection.Open()

Dim command As New SqlCommand("select * from ***MyTable*** FOR XML AUTO ,root('root')", mySqlConnection)
Dim reader As System.Xml.XmlReader = command.ExecuteXmlReader


Dim xml As New XmlDataDocument()
Xml.Load(reader)
 
[0] The xml processing layout seems at large fine with what we see.
[1]>I want the final result to produce htt:\\localhost\file.xml
You can add Save after the Load, something like this.
[tt] Xml.Save(Server.MapPath("file.xml"))[/tt]
[2] If you get blank page, maybe you've to set Page's Content Type to "text/xml". But, you need to show more to be sure, and preferrably further the question to asp.net forum here.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top