Please let me know, How to loop into List of Datatables and what is the argument value we need to set if we use for each loop for that?

1 Like

Hi,

Can you try Rows property (or AsEnumerable method) of the Datatable and set DataRow at TypeArgument as the following?

OR try ForEachRow activity instead of ForEach

image

Regards,

1 Like

Hi @Salman_Faries

For outer loop, since you are iterating through the list of datatables, the type argument will be system.data.datatable.

For inner loop, since you are iterating through each row in the datatable, the type argument will be system.data.datarow.

Hope this helps,
Best Regards.

Hi,

Thanks for the reply. Anyhow, If I set Outer loop as System.data.Datatable, It’s showing "object reference not set to an instance of object error.

Best,
Salman

Hi,

Thanks for the reply Yoichi. I tried your way but it throws error as “Object reference not set to an instance of the object”.

Will you please let me know, I’m given a use case to take an excel file and classify all the order ID’s with the mode of payment like cash/EMI. For that i created different datatables for different mode of payment by storing the whole excel into an “Excel_Datatable” and filtering it and storing it in seperate datatable named “cash_DT”, “EMI_DT”. and looping into the list of datatables. Whether this will work?

Best,
Salman

@Salman_Faries

Whatever you are thinking works.

I guess the problem is you used the name datatable… try changing the name to dt or something

And the second loop try using for each row in datatable directly instead of another for each

Cheers

1 Like

HI,

Hope the following sample helps you.

In this case, it may be better to use Dictionary instead of List, as the following, for example, because we can access each datatable by key (such as “cash”)

Sample20230313-1L.zip (10.9 KB)

note: Just to be sure, it’s better not to use variable named “datatable” (even if it works in the above),because name resolution, may be ambiguous with DataTable class, as @Anil_G metioned.

Regards,

2 Likes

Thanks ! Thats was the issue. It’s resolved!

1 Like

Thanks man! it worked!

1 Like

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