XML output parameters with ADODB in ASP Classic

。_饼干妹妹 提交于 2019-12-03 21:31:56

The reason you receive an error on the adXML line is because there is no DataTypeEnum for this data type.

In ADO 2.6 the ADODB.Command object was extended to support passing and receiving XML data using the ADODB.Stream object.

To pass an XML data type in the ADODB.Command use the CommandStream property

Set stream = Server.CreateObject("ADODB.Stream")
Call stream.Open()
Call stream.WriteText(xml, adWriteChar)

'Set ADODB.Stream to CommandStream before executing ADODB.Command
command.CommandStream = stream
command.Execute(, , adExecuteStream)

To retrieve an XML data type use the dynamic property Output Stream

Set stream = Server.CreateObject("ADODB.Stream")
Call stream.Open()

'Set ADODB.Stream to dynamic property "Output Stream"
command.Properties("Output Stream") = stream
command.Execute(, , adExecuteStream)
'Reset stream position before reading
stream.Position = 0
xml = stream.ReadText

Useful links

I finally could make with a workaround. basically sending the parameter from SQL as a varchar(max) and not as XML, then treating it in ASP as a Object Resulset were I convert the varchar to an XML. Tried up with files of more than 30k characters and still works. Classic ASP code so far:

`

dim objResultseto
set objResultseto = Server.CreateObject("ADODB.RecordSet")
AbrirProcAlmacenado objResultseto, adOpenStatic, objCommand             

if objResultseto.EOF= false then        
 while (objResultseto.EOF = false)

        Set xmlOperaciones = Server.CreateObject("Msxml2.DOMDocument.4.0")
            xmlOperaciones.Async = False
            xmlOperaciones.loadXML(objResultseto("XML_VAR"))
            xmlOperaciones.setProperty "SelectionNamespaces","xmlns:dmo='http://www.webpage.com/'"
            if xmlOperaciones.parseError = 0 then 
                xmlOperaciones.Save("C:\Example.xml")
                sResultado= "OK"
            end if
            objResultseto.movenext
 wend
else
 response.Write("There are no these kind of operations")
 response.end
end if

´

Remember that this is just a workaround.

Cheers!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!