HI All,
I am trying to execute a mysql query and process the data in the form of datatable in a foreach loop.
It is giving me error that datatable type can’t be converted into IEnumerable type. Can anyone please help me.
Regards
Suravi
HI All,
I am trying to execute a mysql query and process the data in the form of datatable in a foreach loop.
It is giving me error that datatable type can’t be converted into IEnumerable type. Can anyone please help me.
Regards
Suravi
Hello @sushree.suravibuyan,
You could also try the following example. As you can see, you may convert the datatable directly to an IEnumerable type.
Main.xaml (8.5 KB)
Thanks @Susana and @acaciomelo for guiding me.
Just a quick note, since this pops up quite a lot:
A DataTable is not an IEnumerable by itself. Internally, the .AsEnumerable() call on it actually takes the .Rows collection and converts that into an IEnumerable(Of DataRow).
That aside, since RowCollection does implement IEnumerator, you can use a ForEach loop on yourDataTable.Rows or use a ForEachRow activity on yourDataTable variable directly.
What about the other way around? I have an Ienumerable and I want a datarow (best i think) or data table. I Assume I need to use an assign activity but can’t work out the expression. The Read Row activity spits out an Ienumerable, and when I put it into the “Add data Row” in the “ArrayRow” input to try and build a datatable from it, the data table just gets written to csv as system.Object. I’ve put a couple of days into this and it’s time to ask for help
Did you ever find a solution? Cause I’m looking for the same thing
If you are passing the DataRow variable then you have to pass it to data row option in add data row…
Ref Below
Just in the place of column1 value you have to your value in reference to your data table column