DataRow.GetParentRowとは? わかりやすく解説

DataRow.GetParentRow メソッド (String)

DataRelation の指定した RelationName を使用して、DataRow の親行を取得します。

名前空間: System.Data
アセンブリ: System.Data (system.data.dll 内)
構文構文

Public Function GetParentRow ( _
    relationName As String _
) As DataRow
Dim instance As DataRow
Dim relationName As String
Dim returnValue As DataRow

returnValue = instance.GetParentRow(relationName)
public DataRow GetParentRow (
    string relationName
)
public:
DataRow^ GetParentRow (
    String^ relationName
)
public DataRow GetParentRow (
    String relationName
)
public function GetParentRow (
    relationName : String
) : DataRow

パラメータ

relationName

DataRelation の RelationName。

戻り値
現在の行の親 DataRow。

例外例外
例外の種類条件

ArgumentException

リレーションシップと行が同じテーブルに属していません。

RowNotInTableException

行がこのテーブルに属していません。

解説解説

DataSet で、データ セットのすべての親 DataRelation オブジェクトのコレクションは、GetParentRows メソッドによって返されます。

DataTable は、ParentRelations プロパティが返す DataRelation オブジェクトのコレクションも格納します。

使用例使用例

GetParentRow を使用して、DataTable 内の各 DataRow の各親行から値を出力する例を次に示します。

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
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);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DataRow.GetParentRow メソッド (DataRelation)

指定した DataRelation を使用して、DataRow の親行を取得します。

名前空間: System.Data
アセンブリ: System.Data (system.data.dll 内)
構文構文

Public Function GetParentRow ( _
    relation As DataRelation _
) As DataRow
Dim instance As DataRow
Dim relation As DataRelation
Dim returnValue As DataRow

returnValue = instance.GetParentRow(relation)
public DataRow GetParentRow (
    DataRelation relation
)
public:
DataRow^ GetParentRow (
    DataRelation^ relation
)
public DataRow GetParentRow (
    DataRelation relation
)
public function GetParentRow (
    relation : DataRelation
) : DataRow

パラメータ

relation

使用する DataRelation。

戻り値
現在の行の親 DataRow。

例外例外
例外の種類条件

ArgumentNullException

この relation は DataTable に属していません。

行が null 参照 (Visual Basic では Nothing) です。

InvalidConstraintException

この行は DataRelation オブジェクトの子テーブルに属していません。

RowNotInTableException

この行はテーブルに属していません。

解説解説

DataSet で、データ セットのすべての親 DataRelation オブジェクトのコレクションは、GetParentRows メソッドによって返されます。

DataTable は、ParentRelations プロパティが返す DataRelation オブジェクトのコレクションも格納します。

使用例使用例

GetParentRow を使用して、DataTable 内の各子 DataRelation の子 DataRow オブジェクトを返す例を次に示します。次に、行の各列の値が出力されます。

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
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);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataRow クラス
DataRow メンバ
System.Data 名前空間
ChildRelations
DataRelation クラス
GetChildRows
GetParentRow
Relations

DataRow.GetParentRow メソッド (String, DataRowVersion)

DataRelation の指定した RelationName と DataRowVersion を使用して、DataRow の親行を取得します。

名前空間: System.Data
アセンブリ: System.Data (system.data.dll 内)
構文構文

Public Function GetParentRow ( _
    relationName As String, _
    version As DataRowVersion _
) As DataRow
Dim instance As DataRow
Dim relationName As String
Dim version As DataRowVersion
Dim returnValue As DataRow

returnValue = instance.GetParentRow(relationName, version)
public DataRow GetParentRow (
    string relationName,
    DataRowVersion version
)
public:
DataRow^ GetParentRow (
    String^ relationName, 
    DataRowVersion version
)
public DataRow GetParentRow (
    String relationName, 
    DataRowVersion version
)
public function GetParentRow (
    relationName : String, 
    version : DataRowVersion
) : DataRow

パラメータ

relationName

DataRelation の RelationName。

version

DataRowVersion 値の 1 つ。

戻り値
現在の行の親 DataRow。

例外例外
例外の種類条件

ArgumentException

リレーションシップと行が同じテーブルに属していません。

ArgumentNullException

relation が null 参照 (Visual Basic では Nothing) です。

RowNotInTableException

行がこのテーブルに属していません。

VersionNotFoundException

要求された DataRowVersion が行にありません。

解説解説

DataSet で、データ セットのすべての親 DataRelation オブジェクトのコレクションは、GetParentRows メソッドによって返されます。

DataTable は、ParentRelations プロパティが返す DataRelation オブジェクトのコレクションも格納します。

HasVersion プロパティを使用して、目的の DataRowVersion が存在するかどうかを確認します。

使用例使用例

GetParentRow を使用して、DataTable 内の各 DataRow の各親行から値を出力する例を次に示します。

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
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);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DataRow.GetParentRow メソッド (DataRelation, DataRowVersion)

指定した DataRelation と DataRowVersion を使用して、DataRow の親行を取得します。

名前空間: System.Data
アセンブリ: System.Data (system.data.dll 内)
構文構文

Public Function GetParentRow ( _
    relation As DataRelation, _
    version As DataRowVersion _
) As DataRow
Dim instance As DataRow
Dim relation As DataRelation
Dim version As DataRowVersion
Dim returnValue As DataRow

returnValue = instance.GetParentRow(relation, version)
public DataRow GetParentRow (
    DataRelation relation,
    DataRowVersion version
)
public:
DataRow^ GetParentRow (
    DataRelation^ relation, 
    DataRowVersion version
)
public DataRow GetParentRow (
    DataRelation relation, 
    DataRowVersion version
)
public function GetParentRow (
    relation : DataRelation, 
    version : DataRowVersion
) : DataRow

パラメータ

relation

使用する DataRelation。

version

取得するデータのバージョンを指定する DataRowVersion 値の 1 つ。

戻り値
現在の行の親 DataRow。

例外例外
例外の種類条件

ArgumentNullException

行が null 参照 (Visual Basic では Nothing) です。

relation は、このテーブルの親リレーションシップに属していません。

InvalidConstraintException

このリレーションシップの子テーブルは、この行が属しているテーブルではありません。

RowNotInTableException

この行はテーブルに属していません。

VersionNotFoundException

このバージョンのデータが行にありません。

解説解説

DataSet で、データ セットのすべての親 DataRelation オブジェクトのコレクションは、GetParentRows メソッドによって返されます。

DataTable は、ParentRelations プロパティが返す DataRelation オブジェクトのコレクションも格納します。

HasVersion プロパティを使用して、目的の DataRowVersion が存在するかどうかを確認します。

使用例使用例

GetParentRow を使用して、DataTable 内の各子 DataRelation の子 DataRow オブジェクトを返す例を次に示します。次に、行の各列の値が出力されます。

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
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);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataRow クラス
DataRow メンバ
System.Data 名前空間
ChildRelations
DataRelation クラス
DataRowVersion
GetChildRows
GetParentRow
Relations

DataRow.GetParentRow メソッド

DataRow の親行を取得します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
DataRow.GetParentRow (DataRelation) 指定した DataRelation を使用して、DataRow の親行を取得します。

.NET Compact Framework によってサポートされています。

DataRow.GetParentRow (String) DataRelation の指定した RelationName を使用して、DataRow の親行を取得します。

.NET Compact Framework によってサポートされています。

DataRow.GetParentRow (DataRelation, DataRowVersion) 指定した DataRelation と DataRowVersion を使用して、DataRow の親行を取得します。

.NET Compact Framework によってサポートされています。

DataRow.GetParentRow (String, DataRowVersion) DataRelation の指定した RelationName と DataRowVersion を使用して、DataRow の親行を取得します。

.NET Compact Framework によってサポートされています。

参照参照

関連項目

DataRow クラス
DataRow メンバ
System.Data 名前空間
ChildRelations
DataRelation クラス
GetChildRows
GetParentRow
Relations



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「DataRow.GetParentRow」の関連用語

DataRow.GetParentRowのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DataRow.GetParentRowのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS