Retrieving XML from ADO using XSL

Retrieving XML from ADO using XSL

Post by Aureli » Fri, 27 Apr 2001 23:12:09



First, thaks to Baptiste DIEU.
I can figure out how can do it, but I am still having problems.

I receive the error: SQLXML: error loading XSL stylesheet

What is wrong with this code?


<%
On Error Resume Next
    Dim cn                  '   As New ADODB.Connection
    Dim cmd                 '   As New ADODB.Command
    Dim cmdOutput           '   As New ADODB.Stream
    dim strSQL

    set cn = CreateObject("ADODB.Connection")
    set cmd = CreateObject("ADODB.Command")
    set cmdOutput = CreateObject("ADODB.Stream")

        cn.Open "Provider=SQLOLEDB.1;Password=sql;User ID=sa;Initial
Catalog=test;Data Source=ANDROMEDA"

        cmdOutput.Open

        strSQL = "SELECT * FROM test_table FOR XML AUTO,elements"

     Set cmd.ActiveConnection = cn

    cmd.CommandText = strSQL
    cmd.CommandType = 1
    'cmd.Dialect = "{C8B521FB-5CF3-11CE-ADE5-00AA0044773D}"

     cmd.Properties("XML Root") = "DATA"

        cmd.Properties("Output Stream") = cmdOutput
    cmd.Properties("Output Encoding") = "Windows-1252"

        cmd.Properties("XSL") = "test.xsl"

    ' execute the command stream
    cmd.Execute , ,1024

    cn.Close

  theoutput = cmdOutput.ReadText

    Response.Write theoutput

     Set cmd = Nothing
    Set cn = Nothing
     Set cmdOutput = Nothing

%>

And another question. What Stream encoding code can i use to make it the
more generic? Thanks

 
 
 

Retrieving XML from ADO using XSL

Post by David Molone » Sat, 28 Apr 2001 10:27:11


Aurelio,

You have not set the "Base Path" property for your XSL template.
The Command object needs to know where the template is:

syntax:
    cmd.Properties("Base Path")  = "C:\XSLTemplates\"

Hope this helps.

DavidM


> First, thaks to Baptiste DIEU.
> I can figure out how can do it, but I am still having problems.

> I receive the error: SQLXML: error loading XSL stylesheet

> What is wrong with this code?


> <%
> On Error Resume Next
>     Dim cn                  '   As New ADODB.Connection
>     Dim cmd                 '   As New ADODB.Command
>     Dim cmdOutput           '   As New ADODB.Stream
>     dim strSQL

>     set cn = CreateObject("ADODB.Connection")
>     set cmd = CreateObject("ADODB.Command")
>     set cmdOutput = CreateObject("ADODB.Stream")

>         cn.Open "Provider=SQLOLEDB.1;Password=sql;User ID=sa;Initial
> Catalog=test;Data Source=ANDROMEDA"

>         cmdOutput.Open

>         strSQL = "SELECT * FROM test_table FOR XML AUTO,elements"

>      Set cmd.ActiveConnection = cn

>     cmd.CommandText = strSQL
>     cmd.CommandType = 1
>     'cmd.Dialect = "{C8B521FB-5CF3-11CE-ADE5-00AA0044773D}"

>      cmd.Properties("XML Root") = "DATA"

>         cmd.Properties("Output Stream") = cmdOutput
>     cmd.Properties("Output Encoding") = "Windows-1252"

>         cmd.Properties("XSL") = "test.xsl"

>     ' execute the command stream
>     cmd.Execute , ,1024

>     cn.Close

>   theoutput = cmdOutput.ReadText

>     Response.Write theoutput

>      Set cmd = Nothing
>     Set cn = Nothing
>      Set cmdOutput = Nothing

> %>

> And another question. What Stream encoding code can i use to make it the
> more generic? Thanks