If tables in a DataSet have a logical relationship, a DataRelation object can make the related records in another table available to us. We can create a DataRelation object whose properties are set to reflect the common keys. We can then use the DataRelation object to get related records. Instead of joining the tables, we call the GetChildRows method of a data row in the parent table, passing the DataRelation object that defines the parent/child relationship to it. The method returns an array of related child records.
The following code illustrates a simple example of getting related records. In this example, the array DRelnArray is set to the child records of the first row in the Customers table. This assumes that the relation CustomesrOrders is added to the DataSet:
Dim RowCtr As Integer Dim DRelnArray() As DataRow
RowCtr = 0 DRelnArray = _ dsCustomersOrders1.Customers(RowCtr).GetChildRows("CustomersOrders") |