A primary function of the DataRelation is to allow navigation from one table to another within the DataSet. In practice, this allows you to retrieve all of the related DataRow objects in one table when given a single DataRow from a related table. For example, if given a DataRow from the Customers table, you can retrieve all of the orders for a particular customer from the Orders table.
The code example below returns an array of DataRow objects (orders) from one table using the DataRelation and the single DataRow from another (customers).
[VB] Dim x() As DataRow = ds.Tables("Customers").ChildRelations("CustOrders"). _ GetChildRows(ds.Tables("Customers").Rows(0)) Console.WriteLine("") Console.WriteLine("Total Child records for CustOrders Relationship = " & _ x.Count.ToString) Console.WriteLine("Total Tables in DataSet = " & ds.Tables.Count.ToString) [C#] DataRow[] x = ds.Tables["Customers"].ChildRelations["CustOrders"] .GetChildRows(ds.Tables["Customers"].Rows[0]); Console.WriteLine(""); Console.WriteLine("Total Child records for CustOrders Relationship = " + x.Count.ToString()); Console.WriteLine("Total Tables in DataSet = " + ds.Tables.Count.ToString());