Re: Display SQL XML Column
- From: Terry <Terry@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 24 Apr 2008 07:38:03 -0700
Thank you for your speedy response.
However, I would like to display the actual XML column (Col4) schema.
Please note that Column 4 (Col4) has a data type of XML.
EXAMPLE:
Col1: oID
Col2: oSysName
Col3: oReferenceNo
Col4: oXml
"Bob Barrows [MVP]" wrote:
Terry wrote:.
How do I display an SQL XML data type (column) within classic ASP?Here's an example I wrote (err, adapted from a SQL BOL topic ... ahem) a
while ago. It applies to using the For XML clause, but hopefully it applies
(or can be adapted) to the the new XML datatype as well. I have not had
occasion to utilize that functionality in classic ASP so I have no examples
written. You might want to check SQL2005 BOL but IIRC, the examples in it
only applied to .Net <grrr>
Anyways, I hope it helps:
<%@ Language=VBScript %>
<%
option explicit
Response.ContentType="text/xml"
dim cn, rs,sQuery, cmd
Const adExecuteStream = &H00000400
Const adCmdText = &H0001
set cn=server.CreateObject("adodb.connection")
cn.open "provider=sqloledb;data source=????;" & _
"user id = ???; password=????;initial catalog=northwind"
Set cmd = Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection = cn
sQuery = "SELECT * FROM PRODUCTS ORDER BY PRODUCTNAME FOR XML auto"
cmd.CommandText = sQuery
cmd.Properties("xml root").Value = "root"
cmd.Properties("Output Stream") = Response
cmd.Execute , , adExecuteStream + adCmdText
set cmd=nothing
cn.close
set cn=nothing
%>
I put the "Response.ContentType ..." line in so you could see that the
results were XML. You don't need that line in your code. Instead of
"cmd.Properties("Output Stream") = Response", you can instantiate a dom
object and have the results stream into it instead: "cmd.Properties("Output
Stream") = xmldoc"
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
- References:
- Display SQL XML Column
- From: Terry
- Re: Display SQL XML Column
- From: Bob Barrows [MVP]
- Display SQL XML Column
- Prev by Date: Re: Display SQL XML Column
- Next by Date: Re: Display SQL XML Column
- Previous by thread: Re: Display SQL XML Column
- Next by thread: Re: Display SQL XML Column
- Index(es):
Relevant Pages
|
|