Gets the collection of parent relations for this DataTable.
[Visual Basic] Public ReadOnly Property ParentRelations As DataRelationCollection [C#] public DataRelationCollection ParentRelations {get;} [C++] public: __property DataRelationCollection* get_ParentRelations(); [JScript] public function get ParentRelations() : DataRelationCollection;
A DataRelationCollection that contains the parent relations for the table; otherwise a null value if no DataRelation objects exist.
[Visual Basic, C#] The following example uses the ParentRelations property to return each parent DataRelation in a DataTable. Each relation is then used as an argument in the GetParentRows method of the DataRow to return an array of rows. The value of each column in the row is then printed.
[Visual Basic] Private Sub GetChildRowsFromDataRelation(myTable As DataTable) Dim arrRows() As DataRow Dim myRel As DataRelation, myRow As DataRow Dim dc As DataColumn, i As Integer For Each myRel In myTable.ParentRelations For Each myRow In myTable.Rows arrRows = myRow.GetParentRows(myRel) ' Print values of rows. For i = 0 To arrRows.Length - 1 For Each dc In myTable.Columns Console.WriteLine(arrRows(i)(dc)) Next dc Next i Next myRow Next myRel End Sub [C#] private void GetChildRowsFromDataRelation(DataTable myTable){ DataRow[] arrRows; foreach(DataRelation myRel in myTable.ParentRelations){ foreach(DataRow myRow in myTable.Rows){ arrRows = myRow.GetParentRows(myRel); // Print values of rows. for(int i = 0; i < arrRows.Length; i++){ foreach(DataColumn dc in myTable.Columns){ Console.WriteLine(arrRows[i][dc]); } } } } }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework - Windows CE .NET
DataTable Class | DataTable Members | System.Data Namespace | ChildRelations | DataRelation | DataSet | Relations