Retrieve Xml

From: pshvarts (pshvarts_at_discussions.microsoft.com)
Date: 10/20/04


Date: Wed, 20 Oct 2004 06:51:03 -0700

Functon below work fine in VB 6.0 project but did not work in ASP and
wscript. The error is "Syntax error or access violation" in line cmd.Execute
, , adExecuteStream
Any idea why?
Thanks for looking

Function GetXmlBySP(sp, cnnStr)
Const adUseClient = 3
Const adTypeText = 2
Const adCRLF = -1
Const adModeRead = 1
Const adCmdStoredProc = 4
Const adExecuteStream = 1024

GetXmlBySP = ""

Set cnn = CreateObject("ADODB.Connection")
cnn.Open cnnStr

Set cnn = CreateObject("ADODB.Connection")
cnn.CursorLocation = adUseClient
cnn.Open cnnStr

Set ostr = CreateObject("ADODB.Stream")
ostr.Type = adTypeText
ostr.LineSeparator = adCRLF
ostr.Mode = adModeRead
ostr.Open

Set cmd = CreateObject("ADODB.Command")
Set cmd.ActiveConnection = cnn
cmd.Properties("Output Stream").Value = ostr
cmd.CommandType = adCmdStoredProc
cmd.CommandText = sp

cmd.Execute , , adExecuteStream 'ERROR in ASP and W(S)Script, work in VB

Set cmd.ActiveConnection = Nothing
cnn.Close
If Err.Number <> 0 Then Exit Function

ostr.Position = 0
Const ReadBytes = 2048
strXMLOutput = ""
Do While Not ostr.EOS
strXMLOutput = strXMLOutput & ostr.ReadText(ReadBytes)
Loop
GetXmlBySP = strXMLOutput
End Function



Relevant Pages