Unable to get the datatable and assign it to a variable

Hi All Friends ,
I am not able to read or select the particular Data from Data table variable and assign it to a particular variable and print that data . please all friends help me on this problem. please find screenshot also for this issue.

Hi @varun_shinde ,

Would you be so kind as to let us know what exactly it is you are trying to achieve?
Do you simply want to retrieve an array of the elements in a given column, or do you want to splice the datatable into smaller datatables ?

Could you tell us what the desired outcome should look like?

If its Array of values β†’

Filter.AsEnumerable().Select(Function(s) s(ColumnNameOrIndex).ToString).ToArray()

If its splicing β†’

Filter.AsEnumerable().Select(Function(s) Res.Clone.LoadDataRow({s("Name"),s("Age"),s("Salary")},False)).CopyToDataTable()

This works, provided you initialize DataTable Res first with the required columns either by using the Add DataColumn Activity or the Build DataTable Activity.

Kind Regards,
Ashwin A.K

1 Like

Hi Ashwin yes i want to retrieve an array of elements from Data table variable.

Hi @varun_shinde ,

Then this ought to help you out:

Filter.AsEnumerable().Select(Function(s) s("Name").ToString).ToArray()
Filter.AsEnumerable().Select(Function(s) s("Age").ToString).ToArray()
Filter.AsEnumerable().Select(Function(s) s("Salary").ToString).ToArray()

Or even

Filter.AsEnumerable().Select(Function(s) String.Format("{0},{1},{2}",s("Name").ToString,s("Age").ToString,s("Salary").ToString)).ToArray()

Kind Regards,
Ashwin A.K

HI @varun_shinde

Method 1
You can try with For each Row in DataTable Activity

Use Assign Activity

LHS β†’ Create an variable
RHS β†’ CurrentRow(β€œColumnName”).Tostring

Method 2

Use Assign Activity

LHS β†’ Create an variable
RHS β†’ Dt.Rows.Item(0)(0)

(0) β†’ Indicate Row
(0) β†’ Indicate column

Regards
Gokul