語言

DataRow.GetParentRow 方法

定義

會得到 的 DataRow父列。

多載

名稱 Description
GetParentRow(DataRelation)

利用指定的 DataRow取得 的DataRelation父列。

GetParentRow(String)

利用指定的 DataRowRelationName取得 的DataRelation父列。

GetParentRow(DataRelation, DataRowVersion)

利用指定的 DataRow、 和 DataRelation取得 的DataRowVersion父列。

GetParentRow(String, DataRowVersion)

利用 、 和 的指定DataRowRelationNameDataRelation條件取得 a DataRowVersion 的父列。

GetParentRow(DataRelation)

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

利用指定的 DataRow取得 的DataRelation父列。

public:
 System::Data::DataRow ^ GetParentRow(System::Data::DataRelation ^ relation);
public System.Data.DataRow? GetParentRow(System.Data.DataRelation? relation);
public System.Data.DataRow GetParentRow(System.Data.DataRelation relation);
member this.GetParentRow : System.Data.DataRelation -> System.Data.DataRow
Public Function GetParentRow (relation As DataRelation) As DataRow

參數

relation
DataRelation

使用。DataRelation

傳回

現在這場爭吵的家長 DataRow 。

例外狀況

不 relation 屬於 DataTable。

-或-

該列為 null。

兒童排有多個父母。

此列不屬於物件的 DataRelation 子資料表。

這排不屬於桌子。

範例

以下範例使用 來GetParentRow回傳 中每個子節點DataRowDataRelation的子DataTable物件。 接著列印該列中每一欄的值。

private void GetParentRowForTable(DataTable thisTable,
    DataRelation relation)
{
    if(thisTable ==null){return;}
    // For each row in the table, print column 1
    // of the parent DataRow.
    DataRow parentRow;
    foreach(DataRow row in thisTable.Rows)
    {
        parentRow = row.GetParentRow(relation);
        Console.Write("\table child row: " + row[1]);
        Console.Write("\table parent row: " + parentRow[1]+ "\n");
    }
}

private void CallGetParentRowForTable()
{
    // An example of calling the function.
    DataTable thisTable = DataSet1.Tables["Products"];
    DataRelation relation = thisTable.ParentRelations[0];
    GetParentRowForTable(thisTable, relation);
}
Private Sub GetParentRowForTable _
   (thisTable As DataTable, relation As DataRelation)
    If thisTable Is Nothing Then
        Return
    End If
    ' For each row in the table, print column 1 
    ' of the parent DataRow.
    Dim parentRow As DataRow
    Dim row As DataRow
    For Each row In  thisTable.Rows
        parentRow = row.GetParentRow(relation)
        Console.Write(ControlChars.Tab & " child row: " _
           & row(1).ToString())
        Console.Write(ControlChars.Tab & " parent row: " _
           & parentRow(1).ToString() & ControlChars.Cr)
    Next row
End Sub
  
Private Sub CallGetParentRowForTable()
    ' An example of calling the function.
    Dim thisTable As DataTable = DataSet1.Tables("Products")
    Dim relation As DataRelation = thisTable.ParentRelations(0)
    GetParentRowForTable(thisTable, relation)
End Sub

備註

在 中 DataSet,資料集所有父 DataRelation 物件的集合由該方法回傳 GetParentRows 。

同時 DataTable 也包含一組 DataRelation 由 ParentRelations 屬性回傳的物件集合。

另請參閱

適用於

GetParentRow(String)

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

利用指定的 DataRowRelationName取得 的DataRelation父列。

public:
 System::Data::DataRow ^ GetParentRow(System::String ^ relationName);
public System.Data.DataRow? GetParentRow(string? relationName);
public System.Data.DataRow GetParentRow(string relationName);
member this.GetParentRow : string -> System.Data.DataRow
Public Function GetParentRow (relationName As String) As DataRow

參數

relationName
String

RelationName一個 DataRelation.

傳回

現在這場爭吵的家長 DataRow 。

例外狀況

關係與列不屬於同一張表格。

兒童排有多個父母。

該排不屬於桌子。

範例

以下範例使用 來GetParentRow從每個DataRowDataTable父列列印值。

private void GetParentRowForTable(
    DataTable thisTable, string relation)
{
    if(thisTable ==null){return;}
    // For each row in the table, print column 1
    // of the parent DataRow.
    DataRow parentRow;
    foreach(DataRow row in thisTable.Rows)
    {
        parentRow = row.GetParentRow(relation);
        Console.Write("\table child row: " + row[1]);
        Console.Write("\table parent row: " + parentRow[1]+ "\n");
    }
}

private void CallGetParentRowForTable()
{
    // An example of calling the function.
    DataTable thisTable = DataSet1.Tables["Products"];
    DataRelation relation = thisTable.ParentRelations[0];
    GetParentRowForTable(thisTable, relation.RelationName);
}
Private Sub GetParentRowForTable( _
    thisTable As DataTable, relation As String)
     If thisTable Is Nothing Then
         Return
     End If

     ' For each row in the table, print column 1 
     ' of the parent DataRow.
     Dim parentRow As DataRow
     Dim row As DataRow
     For Each row In  thisTable.Rows
         parentRow = row.GetParentRow(relation)
         Console.Write(ControlChars.Tab + " child row: " _
            + row(1).ToString())
         Console.Write(ControlChars.Tab + " parent row: " _
            + parentRow(1).ToString() + ControlChars.Cr)
     Next row
End Sub    
    
Private Sub CallGetParentRowForTable()
     ' An example of calling the function.
     Dim thisTable As DataTable = DataSet1.Tables("Products")
     Dim relation As DataRelation = thisTable.ParentRelations(0)
     GetParentRowForTable(thisTable, relation.RelationName)
End Sub

備註

在 中 DataSet,資料集所有父 DataRelation 物件的集合由該方法回傳 GetParentRows 。

同時 DataTable 也包含一組 DataRelation 由 ParentRelations 屬性回傳的物件集合。

適用於

GetParentRow(DataRelation, DataRowVersion)

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

利用指定的 DataRow、 和 DataRelation取得 的DataRowVersion父列。

public:
 System::Data::DataRow ^ GetParentRow(System::Data::DataRelation ^ relation, System::Data::DataRowVersion version);
public System.Data.DataRow? GetParentRow(System.Data.DataRelation? relation, System.Data.DataRowVersion version);
public System.Data.DataRow GetParentRow(System.Data.DataRelation relation, System.Data.DataRowVersion version);
member this.GetParentRow : System.Data.DataRelation * System.Data.DataRowVersion -> System.Data.DataRow
Public Function GetParentRow (relation As DataRelation, version As DataRowVersion) As DataRow

參數

relation
DataRelation

使用。DataRelation

version
DataRowVersion

其中一個 DataRowVersion 值指定要取得的資料版本。

傳回

現在這場爭吵的家長 DataRow 。

例外狀況

該列為 null。

-或-

不 relation 屬於本表的父關係。

兒童排有多個父母。

該關係的子資料表並非該列所屬的那個資料表。

這排不屬於桌子。

該列沒有這個版本的資料。

範例

以下範例使用 來GetParentRow回傳 中每個子節點DataRowDataRelation的子DataTable物件。 接著列印該列中每一欄的值。

private void GetParentRowForTable(DataTable thisTable,
    DataRelation relation,
    DataRowVersion version)
{
    if(thisTable ==null){return;}
    // For each row in the table, print column 1 of the
    // parent DataRow.
    DataRow parentRow;
    foreach(DataRow row in thisTable.Rows)
    {
        parentRow = row.GetParentRow(relation, version);
        Console.Write("\table child row: " + row[1]);
        Console.Write("\table parent row: " + parentRow[1]+ "\n");
    }
}

private void CallGetParentRowForTable()
{
    // An example of calling the function.
    DataTable thisTable = DataSet1.Tables["Products"];
    DataRelation relation = thisTable.ParentRelations[0];
    // Print only original versions of parent rows.
    GetParentRowForTable(thisTable, relation,
        DataRowVersion.Original);
}
Private Sub GetParentRowForTable _
    (thisTable As DataTable, relation As DataRelation, _
    version As DataRowVersion)
    If thisTable Is Nothing Then
        Return
    End If

    ' For each row in the table, print column 1 
    ' of the parent DataRow.
    Dim parentRow As DataRow
    Dim row As DataRow
    For Each row In  thisTable.Rows
        parentRow = row.GetParentRow(relation, version)
        Console.Write(ControlChars.Tab & " child row: " & _
            row(1).ToString())
        Console.Write(ControlChars.Tab & " parent row: " _
            & parentRow(1).ToString() & ControlChars.Cr)
    Next row
End Sub

Private Sub CallGetParentRowForTable()
    ' An example of calling the function.
    Dim thisTable As DataTable = DataSet1.Tables("Products")
    Dim relation As DataRelation = thisTable.ParentRelations(0)

    ' Print only original versions of parent rows.
    GetParentRowForTable(thisTable, relation, _
        DataRowVersion.Original)
End Sub

備註

在 中 DataSet,資料集所有父 DataRelation 物件的集合由該方法回傳 GetParentRows 。

同時 DataTable 也包含一組 DataRelation 由 ParentRelations 屬性回傳的物件集合。

利用該 HasVersion 房產判斷你想要的 DataRowVersion 房產是否存在。

另請參閱

適用於

GetParentRow(String, DataRowVersion)

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

利用 、 和 的指定DataRowRelationNameDataRelation條件取得 a DataRowVersion 的父列。

public:
 System::Data::DataRow ^ GetParentRow(System::String ^ relationName, System::Data::DataRowVersion version);
public System.Data.DataRow? GetParentRow(string? relationName, System.Data.DataRowVersion version);
public System.Data.DataRow GetParentRow(string relationName, System.Data.DataRowVersion version);
member this.GetParentRow : string * System.Data.DataRowVersion -> System.Data.DataRow
Public Function GetParentRow (relationName As String, version As DataRowVersion) As DataRow

參數

relationName
String

RelationName一個 DataRelation.

version
DataRowVersion

這是其中一項 DataRowVersion 價值。

傳回

現在這場爭吵的家長 DataRow 。

例外狀況

關係與列不屬於同一張表格。

兒童排有多個父母。

該排不屬於桌子。

該列沒有被要求 DataRowVersion的 。

範例

以下範例使用 來GetParentRow從每個DataRowDataTable父列列印值。

private void GetParentRowForTable(DataTable thisTable,
    string relation, DataRowVersion version)
{
    if(thisTable ==null){return;}
    // For each row in the table, print column 1
    // of the parent DataRow.
    DataRow parentRow;
    foreach(DataRow row in thisTable.Rows)
    {
        parentRow = row.GetParentRow(relation, version);
        Console.Write("\t child row: " + row[1]);
        Console.Write("\t parent row: " + parentRow[1]+ "\n");
    }
}

private void CallGetParentRowForTable()
{
    // An example of calling the function.
    DataTable thisTable = DataSet1.Tables["Products"];
    DataRelation relation = thisTable.ParentRelations[0];

    // Print only original versions of parent rows.
    GetParentRowForTable(thisTable, relation.RelationName,
        DataRowVersion.Original);
}
Private Sub GetParentRowForTable _
    (thisTable As DataTable, relation As String, _
    version As DataRowVersion)
     If thisTable Is Nothing Then
         Return
     End If
     ' For each row in the table, print column 1 
     ' of the parent DataRow.
     Dim parentRow As DataRow
     Dim row As DataRow
     For Each row In  thisTable.Rows
         parentRow = row.GetParentRow(relation, version)
         Console.Write(ControlChars.Tab & " child row: " _
            & row(1).ToString())
         Console.Write(ControlChars.Tab & " parent row: " _
            & parentRow(1).ToString() & ControlChars.Cr)
     Next row
End Sub
   
Private Sub CallGetParentRowForTable()
     ' An example of calling the function.
     Dim thisTable As DataTable = DataSet1.Tables("Products")
     Dim relation As DataRelation = thisTable.ParentRelations(0)
     ' Print only original versions of parent rows.
     GetParentRowForTable(thisTable, relation.RelationName, _
        DataRowVersion.Original)
End Sub

備註

在 中 DataSet,資料集所有父 DataRelation 物件的集合由該方法回傳 GetParentRows 。

同時 DataTable 也包含一組 DataRelation 由 ParentRelations 屬性回傳的物件集合。

利用該 HasVersion 房產判斷你想要的 DataRowVersion 房產是否存在。

適用於