
Using ADO.NET • Chapter 9 429
one set of data, for every row in the OrderDetails record, we had all the Order
record information as well.This required some ugly code to get the parent-child
relationship in front of the end user.
To set up a DataRelation, we need two DataTable objects in our DataSet: a
Primary key and a Foreign key.These will establish our Parent objects and our
Child objects. For example:
Dim myds As DataSet = New DataSet("Orders")
Dim MyCol() As DataColumn
Add a Primary key to the DataTable to define the parent in the relationship:
MyCol(0) = myds.Tables("Orders").Columns("OrderID")
myds.Tables("Orders").PrimaryKey = MyCol
Add the relation ...