Build Data Table and then implementing a For Each to check it's working - compiling errors

Currently going through the book ‘Learning Robotic Process Automation’ by Alok Mani Tripathi and in particular a section on creating a Data Table.

Essentially he explains to:

  • Create a flowchart
  • Add a sequence
  • In this sequence make up a DataTable
  • Add a ForEach activity to check it’s working

Now I’ve done the first three things but getting compiling errors with the 4th.
When I created the DataTable I ensured the variable had the same name. I then tried to assign the variable as a data table but I could only find ‘system.data.datatable’

The error message readings:

Compiler error(s) encountered processing expression “MyDataTable”
Option Strict On disallows implicit conversions from
'System.Data.DataTable to ‘system.Collections.IEnumerable’

With my limited knowledge it suggests to me that I need to install a valid DataTable variable?

Any help anyone can provide would be so much appreciated.
Struggling with this book tbh due to inconsistent formatting :confused:

Hi Steve,

I’m not familiar with that book in particular, but I can definitely provide you some advice on creating and working with data tables.

So first of all- you’re absolutely right in creating a System.Data.Datatable variable- this is the type that is commonly referred to as a “datatable”. Something you can use to make datatable creation even easier would be trying out the “Build Data Table” activity, which provides a nice wizard that lets you name columns and populate the table with some data. More information on this activity can be found here:

As for why your code is hitting an error on the For Each, I think it’s because you’re using the slightly wrong activity. The “For Each” activity is for enumerable collections, like lists, arrays, etc. If we want to do a “For Each” on a datatable, we should use the “For Each Row” activity, which is datatable specific. Based on the error you provided, I think using the “For Each Row” activity should resolve your problem.

Lastly, I’m sorry to hear you’re having a hard time with the book. Perhaps you’re aware of it, but UiPath offers free training (the very same training I took when joining the company!) on the UiPath Academy. Just click the below link and log in or register and you’ll have access to a number of video courses which should give you a strong foundation of knowledge in the UiPath platform.

Happy Automating!

Best,

Evan

5 Likes

Evan, blimey…what a fantastic reply. Thank you ever so much.

I started the Academy tonight also. :slight_smile:

Astounded at the speed and helpfulness of the reply - thank you very much.