Startseite ¦  was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews ¦  sonstiges
kylix ¦  tutorials ¦  online shop ¦  fotos ¦  Add&Win Gewinnspiel


Willkommen Gast. Bitte einloggen oder registrieren.
17.05.2012, 02:44:40
Übersicht Hilfe Suche Einloggen Registrieren

+  SwissDelphiCenter Forum
|-+  English Forums
| |-+  General Forum
| | |-+  How to get XML from SQL Server 2000 (for XML)?
« vorheriges nächstes »
Seiten: [1] Drucken
Autor Thema: How to get XML from SQL Server 2000 (for XML)?  (Gelesen 1457 mal)
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
Gespeichert
Seiten: [1] Drucken 
« vorheriges nächstes »
Gehe zu:  


Einloggen mit Benutzername, Passwort und Sitzungslänge

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006, Simple Machines LLC Prüfe XHTML 1.0 Prüfe CSS