Solved

sqlserver query to output xml into asp.net page

Posted on 2013-01-25
2
320 Views
Last Modified: 2013-01-25
Hi!

i Have simple data connection like this

Dim GetDataQry As String = "SELECT * from facilities where ItemID=@ItemId FOR XML PATH"
            Dim cmd As New SqlClient.SqlCommand(GetDataQry, conn)

with a SqlDataReader.

but it outputs only text. not xml as the query requests.
how do i get it to output xml into a asp.net page.
0
Comment
Question by:jamppi
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 305 total points
ID: 38820613
If you're writing this out to the page it could be that the browser is hiding the xml tags as unknown html tags, in that case you could try something like:
Response.Write yourxmlstringvar.Replace("<", "&lt;")

Open in new window

0
 

Author Closing Comment

by:jamppi
ID: 38820809
you got me on right track..  i had to change the document properties to
Response.ContentType = "text/xml"

then i got it right!

/J
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now