Parallel For Each doesn't allow implicit conversion

I try to use Parallel For Each for DataTable, but when I try to use it I see a notification:

“Option Strict On” doesn’t allow implicit conversions from “System.Data.DataTable” to “System.Collections.Generic.IEnumerable(Of System.Data.DataTable)”

  • Why Option Strict doesn’t allow implicit this conversion?
  • How to turn off Option Strict?

1 Like

Fine
lets go one by one

Parallel for each activity will take ienumerable of datatable and not just one datatable tat is it takes like a collection of datatable
as you have passed a datatable variable its showing this error

Cheers @GENIUS91

As you want to loop through the rows of data table, try giving it as

datatable.rows

and if you want to loop through columns, give it as datatable.columns @GENIUS91

You cannot use that activity for a datatable as it returns the incorrect type.

You can use datatable.AsEnumerable() and set the type argument as datarow

4 Likes

Thx @TimK ! It really works!
:smiley:

1 Like

If you mark the post as solution it will assist others in the future if they have a similar problem :slight_smile:

1 Like

@TimK

hiello,
i want to use datatable.columns but not getting appropriate type argument
Any suggestions please

Hi so there is an issue using DataColumnCollection, which is the type of dt.Columns, as it does not implement IEnumerable, which is what Parallel.ForEach expects. DataColumnCollection was introduced before generics were implemented in .NET and therefore aren’t really accomodated for.

What are you trying to achieve?

i want to fill input fields from data table
so currently i m able to achieve it using
for each row in a data table and then inside it i am using simple for each column in datatable.columns

but using this it is filling one by one (sequential)
I am trying much more optimised way by filling the input fields all at a time
so i was hoping if parallal for each can help me .

1 Like

Are there a lot of columns?
What have you set as the delay-before and delay-after?
You could just us parallel for each for the rows and then type into each field individually inside a parallel activity?

there are 7 columns
0 for both delay befo and delay after
ok so you mean like this

Yes see if that helps at all. It should speed it up.

hello Palaniyappan !
i want ask you if can help me with some function in uipath ?

1 Like

Hi
Yes @FlorinIonut

Hello,
I tried your solution,Im still getting error - AsEnumerable is not member of System.Data.Datatable

Take a look at that

Yes,can you guide me for following error - Type ‘System.Collections.Generic.IEnumerable`1[System.Data.DataRow]’ cannot be serialized.,
i’m trying to loop datatable in parallel for each.

Thanks