Gets the parent rows of this DataRow using the specified DataRelation.
[Visual Basic] Overloads Public Function GetParentRows( _ ByVal relation As DataRelation _ ) As DataRow () [C#] public DataRow[] GetParentRows( DataRelation relation ); [C++] public: DataRow* GetParentRows( DataRelation* relation ) []; [JScript] public function GetParentRows( relation : DataRelation ) : DataRow[];
Exception Type | Condition |
---|---|
RowNotInTableException | The row doesn't belong to a DataTable. |
ArgumentNullException | The row is a null reference (in Visual Basic Nothing). |
ArgumentException | The DataRelation doesn't belong to this row's DataSet. |
InvalidConstraintException | The relation's child table isn't the table the row belongs to. |
In a DataSet, the collection of all parent DataRelation objects for the data set is returned by the GetParentRelations method.
The DataTable also contains a collection of DataRelation objects, returned by the ParentRelations property.
The following example uses the GetParentRows to return the child DataRow objects for every child DataRelation in a DataTable. The value of each column in the row is then printed.
[Visual Basic]
Private Sub GetChildRowsFromDataRelation(myTable As DataTable) Dim dr As DataRelation Dim arrRows() As DataRow Dim r As DataRow Dim i As Integer Dim dc As DataColumn For Each dr In myTable.ParentRelations For Each r In myTable.Rows arrRows = r.GetParentRows(dr) ' Print values of rows. For i = 0 To UBound(arrRows) For Each dc in myTable.Columns Console.WriteLine(arrRows(i)(dc.ColumnName)) Next dc Next i Next r Next dr End Sub
DataRow Class | DataRow Members | System.Data Namespace | DataRow.GetParentRows Overload List | ChildRelations | DataRelation | GetChildRows | GetParentRow | Relations