DataSet.WriteXml

  • Thread starter Thread starter John Lee
  • Start date Start date
J

John Lee

Hi,

I have a question need your help. I have defined a dataset with two tables
and I also defined a relationship between the two tables. one is Order
another is OrderDetail. I loaded 3 order records and its related order
detail records, when I use .WriteXml() to write out the data, it actually
output 2 order records first and the output all order details altogether
like:

<MyDataSet>
<Order />
<Order />
<Order />
<OrderDetail />
<OrderDetail />
<OrderDetail />
<OrderDetail />
<OrderDetail />
</MyDataSet>

How could I get the xml like:

<MyDataSet>
<Order>
<OrderDetail />
<OrderDetail />
</Order>
<Order>
<OrderDetail />
</Order>
<Order>
<OrderDetail />
<OrderDetail />
</Order>
</MyDataSet>

Thanks very much!
John
 
John,

If you are using a DataRelation set the Nested property to True. This
will acheive the effect you deisre.

Thanks,

Steve
 
You're so close! The DataRelation class has a .Nested property.

-- Craig Yellick, Alto
 
John:

You could reverse engineer the whole process.

Load the second schema using DataSet.ReadXml into a new dataset and you will
haev the correct table structure and dataset.

Then import your order and order detail records from the other dataset.

There are probably other ways and better ways to do this, but this would
work :)
 
Back
Top