Issues with DataTypes


I am trying to iterate through an array of DataRows and write out the content of each one. But I am getting the error System.Data.DataRow cannot be converted to System.Data.DataTable, even I am declaring the variable as DataRow as per following.

Any help would be highly appreciated.


Select returns an array of DataRows - not a DataTable. Therefore you need to use a For Each activity and set the TypeArgument parameter to DataRow. Additionally, you don’t need to declare the item variable used in the For Each activity. The activity will take care of that for you.

1 Like

@mesalcan as @DanielMitchell mentioned for each row works when the input is of datable you can see the assign activity which you have above the for each row,in the value place at last give .copyTodatatable so that the WIlist converted into datatable and then you can for each row.let me know if any thing goes wrong.

1 Like

You were almost right but the thing is the variable WIList is of type Array of DataRow as we are obtaining that from select method in the previous assign activity
β€” so we cannot use a for each row loop with a variable of type array of datarow as it can only take only datatable
β€” we need to use either for each loop and mention the WIList as input and change the type argument as datarow in the property panel of for each loop and then we can iterate through them
β€” we can still use for each row loop but the input should be a datatable like
In the above assign activity Convert that to a datatable rather to a array of datarow
Like this
WorkItems = WorkItems.Select(your conditions).CopyToDatatable()

So that we can use this WorkItems variable I the for each row loop and iterate through the table directly

Hope this would help you
Cheers @mesalcan

1 Like

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