Index out of range in Datatable

Hi,

I’ve taken over some code written by a previous consultancy and have a query:

In a sequence, we add an empty DataTablerow (ArrayRow {“Null”, “Null”, "Null’, “0”}) to a DataTable (DTtenants).

When running, it should add the

  • tenants name
  • tenants relationship
  • tenants age

to the Datatable.

When running it in debug mode there is a log message “Index was out of range. Must be non-negative and less the size of the collection. Parameter name: index”.

In the variables there is Name - index, Variable type - str32, Scope - DoWhile

I cannot supply the Xaml, sorry.

Richard

Was it the ArrayRow index that was out of range or some operation performed on the datatable after the data was inserted? Also you may want to try placing your values {“Null”, "Null … etc) into the arrayrow part of the properties pane of the add data row activity instead of converting into a datatablerow object. Finally, if you’re only adding 3 things, you have 4 in the datatablerow. There is an option to add rows in the create datatable activity that you may need to configure before using add datatablerow.

As your datatable has 3 columns and you are adding 4 column values in array row that’s why you are getting an error.

You can set array in add datarow activity as {“Null”,“Null”,“Null”}

Sorry, wasn’t clear the first time around.

The DataTable has got 4 Columns, the last being Occurrence (int32)

The Datatable looks like this

Name Relationship Age Occurrence
(string) (string) (string) (Int32)

The datatable is then filled with the

  • tenants name
  • relationship
  • age

If I use “comment out” to exclude ‘Relationship’ it works.