DataRow.GetParentRow DataRow.GetParentRow DataRow.GetParentRow DataRow.GetParentRow Method

定義

DataRow の親行を取得します。Gets the parent row of a DataRow.

オーバーロード

GetParentRow(DataRelation) GetParentRow(DataRelation) GetParentRow(DataRelation) GetParentRow(DataRelation)

指定した DataRow を使用して、DataRelation の親行を取得します。Gets the parent row of a DataRow using the specified DataRelation.

GetParentRow(String) GetParentRow(String) GetParentRow(String) GetParentRow(String)

DataRow の指定した RelationName を使用して、DataRelation の親行を取得します。Gets the parent row of a DataRow using the specified RelationName of a DataRelation.

GetParentRow(DataRelation, DataRowVersion) GetParentRow(DataRelation, DataRowVersion) GetParentRow(DataRelation, DataRowVersion) GetParentRow(DataRelation, DataRowVersion)

指定した DataRowDataRelation を使用して、DataRowVersion の親行を取得します。Gets the parent row of a DataRow using the specified DataRelation, and DataRowVersion.

GetParentRow(String, DataRowVersion) GetParentRow(String, DataRowVersion) GetParentRow(String, DataRowVersion) GetParentRow(String, DataRowVersion)

DataRow の指定した RelationNameDataRelation を使用して、DataRowVersion の親行を取得します。Gets the parent row of a DataRow using the specified RelationName of a DataRelation, and DataRowVersion.

GetParentRow(DataRelation) GetParentRow(DataRelation) GetParentRow(DataRelation) GetParentRow(DataRelation)

指定した DataRow を使用して、DataRelation の親行を取得します。Gets the parent row of a DataRow using the specified DataRelation.

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

パラメーター

戻り値

現在の行の親 DataRowThe parent DataRow of the current row.

例外

この relationDataTable に属していません。The relation does not belong to the DataTable.

または-or-

行が null です。The row is null.

子の行に複数の親が含まれます。A child row has multiple parents.

この行は DataRelation オブジェクトの子テーブルに属していません。This row does not belong to the child table of the DataRelation object.

この行はテーブルに属していません。The row does not belong to a table.

次の例では、GetParentRowを子を返すDataRowのすべての子オブジェクトDataRelationで、DataTableします。The following example uses the GetParentRow to return the child DataRow objects for every child DataRelation in a DataTable. 行の各列の値が出力されます。The value of each column in the row is then printed.

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メソッド。In a DataSet, the collection of all parent DataRelation objects for the data set is returned by the GetParentRows method.

DataTableのコレクションを格納もDataRelationによって返されるオブジェクト、ParentRelationsプロパティ。The DataTable also contains a collection of DataRelation objects, returned by the ParentRelations property.

こちらもご覧ください

GetParentRow(String) GetParentRow(String) GetParentRow(String) GetParentRow(String)

DataRow の指定した RelationName を使用して、DataRelation の親行を取得します。Gets the parent row of a DataRow using the specified RelationName of a DataRelation.

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

パラメーター

戻り値

現在の行の親 DataRowThe parent DataRow of the current row.

例外

リレーションシップと行が同じテーブルに属していません。The relation and row do not belong to the same table.

子の行に複数の親が含まれます。A child row has multiple parents.

行がこのテーブルに属していません。The row does not belong to the table.

次の例では、GetParentRowそれぞれの各親の行から値を印刷するDataRowで、DataTableします。The following example uses the GetParentRow to print a value from each parent row of each DataRow in a DataTable.

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メソッド。In a DataSet, the collection of all parent DataRelation objects for the data set is returned by the GetParentRows method.

DataTableのコレクションを格納もDataRelationによって返されるオブジェクト、ParentRelationsプロパティ。The DataTable also contains a collection of DataRelation objects, returned by the ParentRelations property.

GetParentRow(DataRelation, DataRowVersion) GetParentRow(DataRelation, DataRowVersion) GetParentRow(DataRelation, DataRowVersion) GetParentRow(DataRelation, DataRowVersion)

指定した DataRowDataRelation を使用して、DataRowVersion の親行を取得します。Gets the parent row of a DataRow using the specified DataRelation, and 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);
member this.GetParentRow : System.Data.DataRelation * System.Data.DataRowVersion -> System.Data.DataRow
Public Function GetParentRow (relation As DataRelation, version As DataRowVersion) As DataRow

パラメーター

version
DataRowVersion DataRowVersion DataRowVersion DataRowVersion

取得するデータのバージョンを指定する DataRowVersion 値の 1 つ。One of the DataRowVersion values specifying the version of the data to get.

戻り値

現在の行の親 DataRowThe parent DataRow of the current row.

例外

行が null です。The row is null.

または-or-

relation は、このテーブルの親リレーションシップに属していません。The relation does not belong to this table's parent relations.

子の行に複数の親が含まれます。A child row has multiple parents.

このリレーションシップの子テーブルは、この行が属しているテーブルではありません。The relation's child table is not the table the row belongs to.

この行はテーブルに属していません。The row does not belong to a table.

このバージョンのデータが行にありません。The row does not have this version of data.

次の例では、GetParentRowを子を返すDataRowのすべての子オブジェクトDataRelationで、DataTableします。The following example uses the GetParentRow to return the child DataRow objects for every child DataRelation in a DataTable. 行の各列の値が出力されます。The value of each column in the row is then printed.

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メソッド。In a DataSet, the collection of all parent DataRelation objects for the data set is returned by the GetParentRows method.

DataTableのコレクションを格納もDataRelationによって返されるオブジェクト、ParentRelationsプロパティ。The DataTable also contains a collection of DataRelation objects, returned by the ParentRelations property.

使用して、HasVersionプロパティを決定するかどうか、DataRowVersionが存在します。Use the HasVersion property to determine whether the DataRowVersion that you want exists.

こちらもご覧ください

GetParentRow(String, DataRowVersion) GetParentRow(String, DataRowVersion) GetParentRow(String, DataRowVersion) GetParentRow(String, DataRowVersion)

DataRow の指定した RelationNameDataRelation を使用して、DataRowVersion の親行を取得します。Gets the parent row of a DataRow using the specified RelationName of a DataRelation, and DataRowVersion.

public:
 System::Data::DataRow ^ GetParentRow(System::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

パラメーター

戻り値

現在の行の親 DataRowThe parent DataRow of the current row.

例外

リレーションシップと行が同じテーブルに属していません。The relation and row do not belong to the same table.

子の行に複数の親が含まれます。A child row has multiple parents.

行がこのテーブルに属していません。The row does not belong to the table.

要求された DataRowVersion が行にありません。The row does not have the requested DataRowVersion.

次の例では、GetParentRowそれぞれの各親の行から値を印刷するDataRowで、DataTableします。The following example uses the GetParentRow to print a value from each parent row of each DataRow in a DataTable.

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メソッド。In a DataSet, the collection of all parent DataRelation objects for the data set is returned by the GetParentRows method.

DataTableのコレクションを格納もDataRelationによって返されるオブジェクト、ParentRelationsプロパティ。The DataTable also contains a collection of DataRelation objects, returned by the ParentRelations property.

使用して、HasVersionプロパティを決定するかどうか、DataRowVersionが存在します。Use the HasVersion property to determine whether the DataRowVersion that you want exists.

適用対象