Export 2 datatables in 1 DS into 2 XML files

A

al

Greetings,

How can I export two datatables in one dataset to two XML files
separtely. I tried but no luck. The result I get is 1 datatable in
one XML file and 2 datatables in the other XML file, this is the code:


Dim cnstring As String = "data source=pc1; initial
catalog=northwind;integrated security=sspi"

Dim cn As SqlConnection = New SqlConnection(cnstring)
Dim sqlemployees As String = "select * from employees"
Dim sqlcustomers As String = "select * from customers"
Dim ds As New DataSet
Dim Daemp As New SqlDataAdapter(sqlemployees, cnstring)
Dim dacus As New SqlDataAdapter(sqlcustomers, cnstring)

Private Sub employees_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles employees.Click
Daemp.Fill(ds, "employees")
ds.WriteXml("C:\testemployees.xml")
End Sub

Private Sub customers_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles customers.Click
dacus.Fill(ds, "customers")
ds.WriteXml("C:\testcustomers.xml")
End Sub

MTIA,
Grawsha
 
M

Miha Markic

Hi al,

WriteXml dumps whole dataset.
Maybe you could detach one table and export the other and do the inverse
again?
 

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

Top