return xml

P

Poppy

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
 
J

Jan Tielens

Every response of a webservice is in XML...

Can you be a little more specific what your requirements for that xml are?
 
S

Scott M.

Have you looked at the various methods of a DataSet that express its
contents as XML (writeXML, getXML)?
 
D

Dino Chiesa [Microsoft]

maybe you mean an untyped XML string?

Private Function GetDatasetAsXmlString(...) as String
return myDataSet.getXML()
End Function

Scott M. said:
Have you looked at the various methods of a DataSet that express its
contents as XML (writeXML, getXML)?


Poppy said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top