Is there a way to build a datatable with a specific number of rows

When I build datatables; I use a Build Datatable Activity with column headings and every time that I want to add information to it I add a data row using the Add Data Row activity.

I think it would be much more efficient to build the datatable first with the required number of empty rows first and then put the values in them.

Is there a way to create a datatable with a specified number of empty rows?

And, am I wrong in thinking that this would result in a more efficient solution?



i think with add data row when used it will usually add a new datarow and that would be more efficient
because if we have created a datatable with 10 empty rows and if we fill till only 5 then extra 5 empty rows might lead to error while processing or looping through those rows

so i would suggest to use ADD DATAROW activity directly to add new datarows and it will add only till we mention on how many rows to be added to the datatable in exact which is always desirable

Cheers @KamKam

Let’s say that you knew that you would definitely needed 10 rows for this datatable, before you started adding values to it, and that your process will fill each of these 10 rows. So, there is no chance of you having wasted rows at the end of your datatable.

Which would be the better option then? Creating the empty datatable first to the appropriate size or adding a new row every time you want to add data to the datatable?

1 Like

Let’s take in the same case
Suppose if we have add empty rows first and if we face any issue or exception after adding fifth row and if that is handled with TRY CATCH activity the datatable will be now having five rows filled and five rows not filled
And if we now process those records we will face issue while looping through it processing
Yah it’s fine unless we don’t face exception
But if we face we need to handle that scenario as well buddy
So if we have only the number of rows that got added with add Datarow activity along the process without empty rows, then we won’t be facing any issue

cheers @KamKam

1 Like

I get your point.

Adding a row each time plays around many potential issues.

But, in an ideal world. Where there are no errors. Which would get your Bot to perform its task quicker?