Creating relationship between tables in a Dataset based on multiple columns.
Posted on 2005-04-12
I looking for the syntax to create a relationship between tables in a dataset based on multiple columns. Please correct the following sample code.
Private Sub CreateRelation()
' Get the DataColumn objects from two DataTable objects in a DataSet.
Dim parentCol As DataColumn
Dim childCol As DataColumn
' Code to get the DataSet not shown here.
parentCol = DataSet1.Tables("Customers").Columns("CustID","Code")
childCol = DataSet1.Tables("Orders").Columns("CustID","Code")
' Create DataRelation.
Dim relCustOrder As DataRelation
relCustOrder = New DataRelation("CustomersOrders", parentCol, childCol)
' Add the relation to the DataSet.