DataRow.GetParentRows 方法
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得 DataRow 的父資料列。
GetParentRows(DataRelation, DataRowVersion) |
使用指定的 DataRow 和 DataRelation,取得 DataRowVersion 的父資料列。 |
GetParentRows(DataRelation) |
使用指定的 DataRow,取得 DataRelation 的父資料列。 |
GetParentRows(String) |
使用 DataRow 的指定 RelationName,取得 DataRelation 的父資料列。 |
GetParentRows(String, DataRowVersion) |
使用 DataRow 的指定 RelationName 和 DataRelation,取得 DataRowVersion 的父資料列。 |
- 來源:
- DataRow.cs
- 來源:
- DataRow.cs
- 來源:
- DataRow.cs
使用指定的 DataRow 和 DataRelation,取得 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回 中每個子系的DataTable子DataRowDataRelation物件。 然後列印數據列中每個數據行的值。
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。
另請參閱
適用於
.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 |
- 來源:
- 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回 中每個子系的DataTable子DataRowDataRelation物件。 然後列印數據列中每個數據行的值。
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集合。
另請參閱
適用於
.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 |
- 來源:
- 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
傳回
DataRow 物件的陣列,或是長度為零的陣列。
例外狀況
關聯和資料列不屬於相同資料表。
資料列不屬於資料表。
備註
在 中DataSet,方法會傳GetParentRows回數據集的所有父DataRelation物件集合。
DataTable也包含屬性所ParentRelations傳回的物件DataRelation集合。
適用於
.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 |
- 來源:
- DataRow.cs
- 來源:
- DataRow.cs
- 來源:
- DataRow.cs
使用 DataRow 的指定 RelationName 和 DataRelation,取得 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
- version
- DataRowVersion
其中一個 DataRowVersion 值,指定要取得的資料版本。 可能的值為 Default
、Original
、Current
和 Proposed
。
傳回
DataRow 物件的陣列,或是長度為零的陣列。
例外狀況
關聯和資料列不屬於相同資料表。
relation
為 null
。
資料列不屬於資料表。
資料列沒有要求的 DataRowVersion。
備註
在 中DataSet,方法會傳GetParentRows回數據集的所有父DataRelation物件集合。
DataTable也包含屬性所ParentRelations傳回的物件DataRelation集合。
HasVersion使用 屬性來判斷您想要的 是否存在DataRowVersion。
適用於
.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 |