venerable bede
Apr 23rd, 2004, 05:30 AM
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
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
I now need to return the dataset as xml and have no idea how to do it.
Can anyone help ?
Thanks in Advance
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