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!

asp.net > get the result from a SP (in xml, FOR XML AUTO)

Status
Not open for further replies.

bcardoso

Programmer
Sep 21, 2001
2
PT
Hi,

I am using a SP, which has someting like (SELECT ... FROM ... WHERE ... FOR XML AUTO).
The result is in XML, but my question is: how can I retrive that XML (directly to a variable), to send it to the browser via ASP.NET.
I tried SqlDataReader and SqlDataAdapter, but without results.
Thanks,
Benjamim
 
Hi

as far as i understand you like to get the result XML and assign it to a string object ?

how about getting the result into dataset
and calling the ds.GetXml() method?


string SQL = "SELECT * FROM Customers FOR XML AUTO";

DataSet ds = SqlHelper.ExecuteDataset ("User ID=sa;Initial Catalog=Northwind;DataSource=LOCALHOST",CommandType.Text ,SQL );
string XML = ds.GetXml();

or you don't need the FOR XML AUTO
just use the ds.GetXml();

I hope that helps
ronen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top