# DataRow.GetParentRows Method

## Definition

Gets the parent rows of a DataRow.

 GetParentRows(DataRelation, DataRowVersion) Gets the parent rows of a DataRow using the specified DataRelation, and DataRowVersion. GetParentRows(DataRelation) Gets the parent rows of a DataRow using the specified DataRelation. GetParentRows(String) Gets the parent rows of a DataRow using the specified RelationName of a DataRelation. GetParentRows(String, DataRowVersion) Gets the parent rows of a DataRow using the specified RelationName of a DataRelation, and DataRowVersion.

## GetParentRows(DataRelation, DataRowVersion)

Gets the parent rows of a DataRow using the specified DataRelation, and 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()``

#### Parameters

relation
DataRelation

The DataRelation to use.

version
DataRowVersion

One of the DataRowVersion values specifying the version of the data to get.

#### Returns

DataRow[]

An array of DataRow objects or an array of length zero.

#### Exceptions

The DataRelation does not belong to this row's DataSet.

The row is `null`.

The relation's child table is not the table the row belongs to.

The row does not belong to a DataTable.

The row does not have the requested DataRowVersion.

### Examples

The following example uses the GetParentRows 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 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
``````

### Remarks

In a DataSet, the collection of all parent DataRelation objects for the data set is returned by the GetParentRows method.

The DataTable also contains a collection of DataRelation objects, returned by the ParentRelations property.

Use the HasVersion property to determine whether the DataRowVersion that you want exists.

## GetParentRows(DataRelation)

Gets the parent rows of a DataRow using the specified 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()``

#### Parameters

relation
DataRelation

The DataRelation to use.

#### Returns

DataRow[]

An array of DataRow objects or an array of length zero.

#### Exceptions

The DataRelation does not belong to this row's DataSet.

The row is `null`.

The relation's child table is not the table the row belongs to.

The row does not belong to a DataTable.

### Examples

The following example uses the GetParentRows 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 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
``````

### Remarks

In a DataSet, the collection of all parent DataRelation objects for the data set is returned by the GetParentRows method.

The DataTable also contains a collection of DataRelation objects, returned by the ParentRelations property.

## GetParentRows(String)

Gets the parent rows of a DataRow using the specified RelationName of a 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()``

#### Parameters

relationName
String

The RelationName of a DataRelation.

#### Returns

DataRow[]

An array of DataRow objects or an array of length zero.

#### Exceptions

The relation and row do not belong to the same table.

The row does not belong to the table.

### Remarks

In a DataSet, the collection of all parent DataRelation objects for the data set is returned by the GetParentRows method.

The DataTable also contains a collection of DataRelation objects, returned by the ParentRelations property.

## GetParentRows(String, DataRowVersion)

Gets the parent rows of a DataRow using the specified RelationName of a DataRelation, and 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()``

#### Parameters

relationName
String

The RelationName of a DataRelation.

version
DataRowVersion

One of the DataRowVersion values specifying the version of the data to get. Possible values are `Default`, `Original`, `Current`, and `Proposed`.

#### Returns

DataRow[]

An array of DataRow objects or an array of length zero.

#### Exceptions

The relation and row do not belong to the same table.

The `relation` is `null`.

The row does not belong to the table.

The row does not have the requested DataRowVersion.

### Remarks

In a DataSet, the collection of all parent DataRelation objects for the data set is returned by the GetParentRows method.

The DataTable also contains a collection of DataRelation objects, returned by the ParentRelations property.

Use the HasVersion property to determine whether the DataRowVersion that you want exists.
{"ft_lang_label":"__label__en","ft_lang_prob":0.5012211,"math_prob":0.65958935,"size":7221,"snap":"2022-05-2022-21","text_gpt3_token_len":1555,"char_repetition_ratio":0.246917,"word_repetition_ratio":0.69894737,"special_character_ratio":0.18792412,"punctuation_ratio":0.1766129,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97330564,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-05-21T14:08:50Z\",\"WARC-Record-ID\":\"<urn:uuid:56ca2a7d-eeea-4adc-9bab-870c0b0a1b47>\",\"Content-Length\":\"81425\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4125fc82-0c3f-49b7-9aae-d77b206e3d74>\",\"WARC-Concurrent-To\":\"<urn:uuid:69d24943-da63-4297-a90e-db6f8e43639a>\",\"WARC-IP-Address\":\"23.205.31.117\",\"WARC-Target-URI\":\"https://docs.microsoft.com/en-us/dotnet/api/system.data.datarow.getparentrows?view=net-6.0\",\"WARC-Payload-Digest\":\"sha1:W2W56B6HMV5K6AZT63OPVNZDJ7353APE\",\"WARC-Block-Digest\":\"sha1:3R5YEOJKLMCPQYTRSJHVQ3CAJCGCF4HK\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-21/CC-MAIN-2022-21_segments_1652662539101.40_warc_CC-MAIN-20220521112022-20220521142022-00331.warc.gz\"}"}