Friday, February 24, 2012

display sql xml result

hi all...
i'm using the command below to get a recodset from a sql2000 in a xml
structure.
select * from tb_perguntas FOR XML RAW
i know that with this command i can get a result like this:.
<Customers CustomerID="ALFKI" CompanyName="Alfreds Futterkiste">
<Orders OrderID="10643" OrderDate="08/25/1997" />
<Orders OrderID="11011" OrderDate="04/09/1998" />
</Customers>
i'm having problems getting this xml string from a ASP page.
i tried:
<%
Dim connObj
Set connObj = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
connObj.ConnectionString = "DRIVER={SQL
Server};SERVER=y;UID=x;PWD=z;DATABASE=h"
connObj.Open
Set rs = connObj.Execute("select * from tb_perguntas FOR XML RAW")
response.write( "rs:" & rs.fields(0).value)
%>
the only thing i want it's display the complete string SQL returned.
please help.
thanks.
please help.
You need to use the ICommandStream interface and not the recordset to get
your XML back. See the documentation for examples.
Also, FOR XML raw gives you no hierarchy in the XML, use the AUTO mode or
EXPLICIT mode instead in 2000 (and the PATH mode in 2005).
Best regards
Michael
"rodrigo" <emaildorodrigo@.yahoo.com> wrote in message
news:%23XeLzaYWGHA.3328@.TK2MSFTNGP02.phx.gbl...
> hi all...
> i'm using the command below to get a recodset from a sql2000 in a xml
> structure.
> select * from tb_perguntas FOR XML RAW
> i know that with this command i can get a result like this:.
> <Customers CustomerID="ALFKI" CompanyName="Alfreds Futterkiste">
> <Orders OrderID="10643" OrderDate="08/25/1997" />
> <Orders OrderID="11011" OrderDate="04/09/1998" />
> </Customers>
> i'm having problems getting this xml string from a ASP page.
> i tried:
> <%
> Dim connObj
> Set connObj = Server.CreateObject("ADODB.Connection")
> Set rs = Server.CreateObject("ADODB.Recordset")
> connObj.ConnectionString = "DRIVER={SQL
> Server};SERVER=y;UID=x;PWD=z;DATABASE=h"
> connObj.Open
> Set rs = connObj.Execute("select * from tb_perguntas FOR XML RAW")
> response.write( "rs:" & rs.fields(0).value)
> %>
> the only thing i want it's display the complete string SQL returned.
> please help.
> thanks.
> please help.
>

No comments:

Post a Comment