DataRow.GetParentRows 方法

定義

取得 DataRow 的父資料列。

多載

GetParentRows(DataRelation, DataRowVersion)

使用指定的 DataRowDataRelation,取得 DataRowVersion 的父資料列。

GetParentRows(DataRelation)

使用指定的 DataRow,取得 DataRelation 的父資料列。

GetParentRows(String)

使用 DataRow 的指定 RelationName,取得 DataRelation 的父資料列。

GetParentRows(String, DataRowVersion)

使用 DataRow 的指定 RelationNameDataRelation,取得 DataRowVersion 的父資料列。

GetParentRows(DataRelation, DataRowVersion)

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

使用指定的 DataRowDataRelation,取得 DataRowVersion 的父資料列。

public:
 cli::array <System::Data::DataRow ^> ^ GetParentRows(System::Data::DataRelation ^ relation, System::Data::DataRowVersion version);
public System.Data.DataRow[] GetParentRows (System.Data.DataRelation? relation, System.Data.DataRowVersion version);
public System.Data.DataRow[] GetParentRows (System.Data.DataRelation relation, System.Data.DataRowVersion version);
member this.GetParentRows : System.Data.DataRelation * System.Data.DataRowVersion -> System.Data.DataRow[]
Public Function GetParentRows (relation As DataRelation, version As DataRowVersion) As DataRow()

參數

relation
DataRelation

要使用的 DataRelation

version
DataRowVersion

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

傳回

DataRow 物件的陣列,或是長度為零的陣列。

例外狀況

DataRelation 不屬於這個資料列的 DataSet

資料列為 null

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

資料列不屬於 DataTable

資料列沒有要求的 DataRowVersion

範例

下列範例會使用 傳GetParentRows回 中每個子系的DataTableDataRowDataRelation物件。 然後列印數據列中每個數據行的值。

Private Sub GetChildRowsFromDataRelation(table As DataTable, ver As DataRowVersion)
    Dim relation As DataRelation
    Dim arrRows() As DataRow
    Dim row As DataRow
    Dim i As Integer
    Dim column As DataColumn 
 
    For Each relation In table.ParentRelations
      For Each row In table.Rows
          arrRows = row.GetParentRows(relation, ver)
          ' Print values of rows.
          For i = 0 To arrRows.GetUpperBound(0)
             For Each column in table.Columns
                Console.WriteLine(arrRows(i)(column.ColumnName))
             Next column
          Next i
       Next row
    Next relation
End Sub

備註

在 中DataSet,方法會傳GetParentRows回數據集的所有父DataRelation物件集合。

DataTable也包含屬性所ParentRelations傳回的物件DataRelation集合。

HasVersion使用 屬性來判斷您想要的 是否存在DataRowVersion

另請參閱

適用於

GetParentRows(DataRelation)

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

使用指定的 DataRow,取得 DataRelation 的父資料列。

public:
 cli::array <System::Data::DataRow ^> ^ GetParentRows(System::Data::DataRelation ^ relation);
public System.Data.DataRow[] GetParentRows (System.Data.DataRelation? relation);
public System.Data.DataRow[] GetParentRows (System.Data.DataRelation relation);
member this.GetParentRows : System.Data.DataRelation -> System.Data.DataRow[]
Public Function GetParentRows (relation As DataRelation) As DataRow()

參數

relation
DataRelation

要使用的 DataRelation

傳回

DataRow 物件的陣列,或是長度為零的陣列。

例外狀況

DataRelation 不屬於這個資料列的 DataSet

資料列為 null

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

資料列不屬於 DataTable

範例

下列範例會使用 傳GetParentRows回 中每個子系的DataTableDataRowDataRelation物件。 然後列印數據列中每個數據行的值。

Private Sub GetChildRowsFromDataRelation(table As DataTable)
    Dim relation As DataRelation
    Dim arrRows() As DataRow
    Dim row As DataRow
    Dim i As Integer
    Dim column As DataColumn 
 
    For Each relation In table.ParentRelations
      For Each row In table.Rows
          arrRows = row.GetParentRows(relation)
          ' Print values of rows.
          For i = 0 To arrRows.GetUpperBound(0)
             For Each column in table.Columns
                Console.WriteLine(arrRows(i)(column.ColumnName))
             Next column
          Next i
       Next row
    Next relation
 End Sub

備註

在 中DataSet,方法會傳GetParentRows回數據集的所有父DataRelation物件集合。

DataTable也包含屬性所ParentRelations傳回的物件DataRelation集合。

另請參閱

適用於

GetParentRows(String)

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

使用 DataRow 的指定 RelationName,取得 DataRelation 的父資料列。

public:
 cli::array <System::Data::DataRow ^> ^ GetParentRows(System::String ^ relationName);
public System.Data.DataRow[] GetParentRows (string? relationName);
public System.Data.DataRow[] GetParentRows (string relationName);
member this.GetParentRows : string -> System.Data.DataRow[]
Public Function GetParentRows (relationName As String) As DataRow()

參數

relationName
String

RelationNameDataRelation

傳回

DataRow 物件的陣列,或是長度為零的陣列。

例外狀況

關聯和資料列不屬於相同資料表。

資料列不屬於資料表。

備註

在 中DataSet,方法會傳GetParentRows回數據集的所有父DataRelation物件集合。

DataTable也包含屬性所ParentRelations傳回的物件DataRelation集合。

適用於

GetParentRows(String, DataRowVersion)

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

使用 DataRow 的指定 RelationNameDataRelation,取得 DataRowVersion 的父資料列。

public:
 cli::array <System::Data::DataRow ^> ^ GetParentRows(System::String ^ relationName, System::Data::DataRowVersion version);
public System.Data.DataRow[] GetParentRows (string? relationName, System.Data.DataRowVersion version);
public System.Data.DataRow[] GetParentRows (string relationName, System.Data.DataRowVersion version);
member this.GetParentRows : string * System.Data.DataRowVersion -> System.Data.DataRow[]
Public Function GetParentRows (relationName As String, version As DataRowVersion) As DataRow()

參數

relationName
String

RelationNameDataRelation

version
DataRowVersion

其中一個 DataRowVersion 值,指定要取得的資料版本。 可能的值為 DefaultOriginalCurrentProposed

傳回

DataRow 物件的陣列,或是長度為零的陣列。

例外狀況

關聯和資料列不屬於相同資料表。

relationnull

資料列不屬於資料表。

資料列沒有要求的 DataRowVersion

備註

在 中DataSet,方法會傳GetParentRows回數據集的所有父DataRelation物件集合。

DataTable也包含屬性所ParentRelations傳回的物件DataRelation集合。

HasVersion使用 屬性來判斷您想要的 是否存在DataRowVersion

適用於