Wednesday, March 21, 2012

save xml to file??

here is my code for extracting xml and saving it to a file, but i am not
having success in saving it to a file. can someone review and give
suggestions or help? am i on the right track?
<%
Response.ContentType = "text/xml"
Dim oCmd, sSQL
sSQL = "<root><sql:query xmlns:sql='urn:schemas-microsoft-com:xml-sql'>" & _
"select * from customers for xml auto, elements</sql:query></root>"
Set oCmd = Server.CreateObject("ADODB.Command")
oCmd.ActiveConnection = "myconnection string"
Dim adoStreamQuery
Set adoStreamQuery = Server.CreateObject("ADODB.Stream")
adoStreamQuery.Open
adoStreamQuery.WriteText sSQL, adWriteChar
adoStreamQuery.Position = 0
oCmd.CommandStream = adostreamquery
oCmd.Dialect = "{5D531CB2-E6Ed-11D2-B252-00C04F681B71}"
oCmd.Properties("Output Stream") = Response
oCmd.Execute , , 1024
adoStreamQuery.SaveToFile c:\xmlfile.xml
%>
i get the following error message:
Error Type:
Microsoft VBScript compilation (0x800A0400)
Expected statement
/Project2/test2.asp, line 26, column 28
adoStreamQuery.SaveToFile c:\xmlfile.xml
--^
please advise.
The save to file parameter is a string - quotes around the file name might
help.
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"snickerskid" <snickerskid@.discussions.microsoft.com> wrote in message
news:BBC5A090-E6AA-46A5-9AB2-C4B1D6C5E18C@.microsoft.com...
> here is my code for extracting xml and saving it to a file, but i am not
> having success in saving it to a file. can someone review and give
> suggestions or help? am i on the right track?
> <%
> Response.ContentType = "text/xml"
> Dim oCmd, sSQL
> sSQL = "<root><sql:query xmlns:sql='urn:schemas-microsoft-com:xml-sql'>" &
> _
> "select * from customers for xml auto, elements</sql:query></root>"
> Set oCmd = Server.CreateObject("ADODB.Command")
> oCmd.ActiveConnection = "myconnection string"
> Dim adoStreamQuery
> Set adoStreamQuery = Server.CreateObject("ADODB.Stream")
> adoStreamQuery.Open
> adoStreamQuery.WriteText sSQL, adWriteChar
> adoStreamQuery.Position = 0
> oCmd.CommandStream = adostreamquery
> oCmd.Dialect = "{5D531CB2-E6Ed-11D2-B252-00C04F681B71}"
> oCmd.Properties("Output Stream") = Response
> oCmd.Execute , , 1024
> adoStreamQuery.SaveToFile c:\xmlfile.xml
> %>
> i get the following error message:
> Error Type:
> Microsoft VBScript compilation (0x800A0400)
> Expected statement
> /Project2/test2.asp, line 26, column 28
> adoStreamQuery.SaveToFile c:\xmlfile.xml
> --^
> please advise.
>
|||thanks a bunch. that worked and helped. =) however, it isn't saving the
results...it is saving the text of what sSQL is equal to. any ideas on how
to pipe the results to a file?
"Roger Wolter[MSFT]" wrote:

> The save to file parameter is a string - quotes around the file name might
> help.
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
> Use of included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm
> "snickerskid" <snickerskid@.discussions.microsoft.com> wrote in message
> news:BBC5A090-E6AA-46A5-9AB2-C4B1D6C5E18C@.microsoft.com...
>
>

No comments:

Post a Comment