ivasi
Gast
|
 |
« am: 14.05.2002, 08:27:23 » |
|
Hi! I have a problem with retrieving a XML result from SQL Server 2000. I am using a stored procedure which gives XML (with FOR XML clause, at the end of sp). How to get this XML as a string in Delphi 5. I have tried with BDE, ADO..., and nothing...
But, this thing works in VB in this way:
Private Sub cmdXML_Click() Dim oXML As MSXML.DOMDocument Dim oCon As ADODB.Connection Dim sXML As String Dim oStream As Stream Dim cmCmd As ADODB.Command Dim sResponseStream As ADODB.Stream
Set oCon = CreateObject("ADODB.Connection") oCon.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Data Source=zoranp;Initial Catalog=Northwind" oCon.Open If oCon.State = 0 Then End
Set cmCmd = New Command Set cmCmd.ActiveConnection = oCon
With cmCmd .CommandType = adCmdStoredProc .CommandText = "Pop" .Parameters.Append .CreateParameter("@CustomerID", adWChar, adParamInput, 5, "A%%%%") End With Set sResponseStream = New ADODB.Stream sResponseStream.Open
cmCmd.Properties("Output Stream") = sResponseStream cmCmd.Execute , , adExecuteStream
Set oXML = CreateObject("MSXML.DOMDocument") oXML.loadXML ("<root>" & sResponseStream.ReadText & "</root>")
oXML.save (App.Path & "/_XML/report.xml")
Set oXML = Nothing Set oCon = Nothing Set cmCmd = Nothing Set sResponseStream = Nothing
End Sub
|