Results 1 to 9 of 9

Thread: Return XML

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Return XML

    The following function is used in my webservice which returns a dataset.
    I now need to return the dataset as xml and have no idea how to do it.
    Can anyone help ?
    Thanks in Advance

    Code:
    Private Function GetDataSetXML(ByVal strSQL As String) As dataset
            '1. Create a connection
            Dim connString As String
            connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "C:\blobdata\data.mdb" & ";"
            Dim myConnection As New OleDbConnection(connString)
            '2. Create the command object, passing in the SQL string    
            Dim myCommand As New OleDbCommand(strSQL, myConnection)
            myConnection.Open()
            '3. Create the DataAdapter
            Dim myDataAdapter As New OleDbDataAdapter()
            myDataAdapter.SelectCommand = myCommand
            '4. Populate the DataSet and close the connection
            Dim myDataSet As New DataSet()
            myDataAdapter.Fill(myDataSet)
            myConnection.Close()
            'Return the DataSet
            Return myDataset
        End Function

    Parksie

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    Try using the SQLXML class, which allows you to pull the data in XML format from any relational database.

    Here's a link
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018
    Thanks.

    I'll give it a go.

    Parksie

  4. #4
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    You can also use the "FOR XML" clause in your sql statment that is returning the data. Sql will do the xml conversion for you.

    Or

    You can use the dataset and use its .WriteXML method to get the xml.

  5. #5
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    "FOR XML" doesn't work with all relational databases does it???
    I know it works with SQL Server 2000, because it has built-in XML support, but does it work with Access or Oracle, etc...??
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  6. #6
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Your right...sorry

    I was thinking the poster was using SQL Server when I was writing that...

  7. #7

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018
    Yeah, I'm using a crappy access back-end so the SQL XML is out of the question.

    I tried the .getxml but it creates one long string. Unfortunatly I'm writing this service for a graphics guy and he says its of no use to him.

    Bloody graphic designers.
    Last edited by venerable bede; Apr 27th, 2004 at 06:03 AM.

    Parksie

  8. #8

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018
    Do either of you guys know where I can find an example of populating an array from a dataset.

    He's just told me that he now wants an array !!!!

    Bloody Designers !!!!!

    Parksie

  9. #9
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    The SQLXML Class will work with any relational database.
    It's the FOR XML clause that only works with SQL Server 2000.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width