Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

DataRow.SetParentRow Method (DataRow, DataRelation)

Sets the parent row of a DataRow with specified new parent DataRow and DataRelation.

Namespace:  System.Data
Assembly:  System.Data (in System.Data.dll)

public void SetParentRow(
	DataRow parentRow,
	DataRelation relation
)

Parameters

parentRow
Type: System.Data.DataRow

The new parent DataRow.

relation
Type: System.Data.DataRelation

The relation DataRelation to use.

ExceptionCondition
RowNotInTableException

One of the rows does not belong to a table

ArgumentNullException

One of the rows is null.

ArgumentException

The relation does not belong to the DataRelationCollection of the DataSet object.

InvalidConstraintException

The relation's child DataTable is not the table this row belongs to.

The following example sets the parent row of a specific child row.

Private Sub SetParent()
    ' Get a ParentRow and a ChildRow from a DataSet. 
    Dim childRow As DataRow = _
        DataSet1.Tables("Orders").Rows(1)
    Dim parentRow As DataRow = _
        DataSet1.Tables("Customers").Rows(20)

    ' Set the parent row of a DataRelation.
    childRow.SetParentRow(parentRow, _
        DataSet1.Relations("CustomerOrders"))
End Sub

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft