DataSet.WriteXml and linked tables

  • Thread starter Thread starter Kristoffer Persson
  • Start date Start date
K

Kristoffer Persson

Let's say I have three tables:

Customer
Order
OrderLine

Now, using a DataSet, I would like to select one customer and get
information that looks like this:

<Customer>
<CustomerID>100</CustomerID>
<Order>
<OrderNo>12345</OrderNo>
<OrderLine>
<LineNo>1</LineNo>
<ArticleNo>545</ArticleNo>
<Quantity>1</Quantity>
</OrderLine>
<OrderLine>
<LineNo>2</LineNo>
<ArticleNo>343</ArticleNo>
<Quantity>2</Quantity>
</OrderLine>
</Order>
</Customer>

Is this possible? Does the DataSet class support this?

- Kristoffer -
 
Yes.

Take this XML and open it in VS .NET. Then right click anywhere on the opened file and select "Create Schema". This will create an .xsd file for you. Then in the xsd file, right click and select "Generate Dataset". This will generate a typed dataset, in which you can use DataSet.WriteXML to get the XML you want to create.
 
Back
Top