Retrieve all Rows of a particular column from Datatable and assign it to an DataRow[]

Hi, I need help to Retrieve all Rows of a particular column from Datatable and assign it to an DataRow. so I can use that DataRow for next process.

Hi @Jadeja_Chandravijaysinh
welcome to forum

actually what issue are u are facing?

@Jadeja_Chandravijaysinh

Use the below expression to get only one column data…

to get Data Table:
TransactionData.DefaultView.ToTable(False,“ProductURL”)

To get Rows

TransactionData.DefaultView.ToTable(False,“ProductURL”).rows

Hi Nived Nambiar, Not exactly an issue but. I need a syntax for to: Get all the Rows of a particular Column (i.e. Column= Country has rows= USA, Russia, India, etc.) and store those columns in a DataRow array object.

Hi,

if you want only “ProductURL” column you can use this:
dt.AsEnumerable.Select(Function(x) x(“ProductURL”))

dt.Select(filter) : this one filter the rows but return the entire row with all columns.

Regards, Gio

1 Like

Hi @Jadeja_Chandravijaysinh

use the method suggested by @q.gio it will work :blush:

it is show the error like : can not assign from type 'system.data.enumerableRowsCollection’1 [system.Object] to ‘System.Data.DataRow’ in assign activity.

Did you try below?

Hi,

try to add .ToArray method:

dt.AsEnumerable.Select(Function(x) x(“ProductURL”)).ToArray

Gio

yes but, it is throwing the same errorcan not assign from type 'system.data.enumerableRowsCollection’1 [system.Object] to ‘System.Data.DataRow.Array

Because it is datarow collection…
Why you assigning it to array?

We have For each row to loop through the data row collections…

yes but, i need to assign the values of Data Row collections to Data row array

Use the below expression to get only one column data…

TransactionData.DefaultView.ToTable(False,“ProductURL”).Select It will give you array

Thanks for solving the issue pravin.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.