Problem with Dataset.WriteXML

  • Thread starter Thread starter Morten Snedker
  • Start date Start date
M

Morten Snedker

This is the code:

Try
Dim con As New
SqlConnection("server=comwirsql;database=comwirdirect;Trusted_Connection=yes")
Dim dGetData As SqlDataAdapter = New
SqlDataAdapter("sp_AccessUser2FTP", con)
dGetData.SelectCommand.CommandType =
Data.CommandType.StoredProcedure

Dim dDataset As New Data.DataSet
dGetData.Fill(dDataset)

With dDataset
.DataSetName = "AccessUser"
.WriteXml("E:\output.xml")
'.WriteXmlSchema("e:\output.xsd")
End With

dDataset.Dispose()
dGetData.Dispose()
Catch ex As Exception
Response.Write(ex.Message)
End Try

This creates:

<AccessUser>
<Table>
<Lastname>hans</Lastname>
<Emailaddress1 />
</Table>
....

How do I avoid the creation of the Table tag?

Regards /Snedker
 
Hi,

DataSet is memory representation of collection of tables. Thus you will
always have some tag representing table in dataset. You can use DataTable
instead of DataSet to reduce number of tags in resulting xml.

Regards,
Ladislav
 
Thanks for input. Changed to datatable and all's well!

Regards /Snedker

Ladislav Mrnka skrev:
 
Back
Top