閱讀英文

共用方式為


DataRow.SetParentRow 方法

定義

設定 DataRow 的父資料列。

多載

SetParentRow(DataRow)

使用指定的新父 DataRow,設定 DataRow 的父資料列。

SetParentRow(DataRow, DataRelation)

使用指定的新父 DataRowDataRow,設定 DataRelation 的父資料列。

SetParentRow(DataRow)

來源:
DataRow.cs
來源:
DataRow.cs
來源:
DataRow.cs

使用指定的新父 DataRow,設定 DataRow 的父資料列。

C#
public void SetParentRow (System.Data.DataRow? parentRow);
C#
public void SetParentRow (System.Data.DataRow parentRow);

參數

parentRow
DataRow

新的父 DataRow

適用於

.NET 9 及其他版本
產品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

SetParentRow(DataRow, DataRelation)

來源:
DataRow.cs
來源:
DataRow.cs
來源:
DataRow.cs

使用指定的新父 DataRowDataRow,設定 DataRelation 的父資料列。

C#
public void SetParentRow (System.Data.DataRow? parentRow, System.Data.DataRelation? relation);
C#
public void SetParentRow (System.Data.DataRow parentRow, System.Data.DataRelation relation);

參數

parentRow
DataRow

新的父 DataRow

relation
DataRelation

要使用的關聯 DataRelation

例外狀況

其中一個資料列不屬於資料表。

其中一個資料列為 null

關聯的子 DataTable 不是這個資料列所屬的資料表。

範例

下列範例會設定特定子數據列的父數據列。

VB
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

適用於

.NET 9 及其他版本
產品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1