I do have 6k+ rows and where i need to remove few rows but throws exception

Hi all

I do have 6k + rows and while try to remove few rows getting like this error

RemoteException wrapping System.InvalidOperationException: Collection was modified; enumeration operation might not execute.
at System.Data.RBTree1.RBTreeEnumerator.MoveNext() at UiPath.Core.Activities.ForEach1.InternalExecute(NativeActivityContext context, IEnumerable values)
at UiPath.Core.Activities.ForEach`1.GetStateAndExecute(NativeActivityContext context, ActivityInstance completedInstance)
at System.Activities.Runtime.ActivityCompletionCallbackWrapper.Invoke(NativeActivityContext context, ActivityInstance completedInstance)
at System.Activities.Runtime.CompletionCallbackWrapper.CompletionWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

Please kindly Let me Know

thank you!!!

can you share the statement which you are trying to execute?

You can’t delete the rows while looping the datatable. You could add the rows you want to delete to a separate list, and after looping the table, create a new loop on the list of rows to delete where you actually delete the rows.

Sample code, which you can adapt to UiPath:

@vineelag

Looks like you are trying to delete inside a loop …that is not possible…either use filter datatable or linq to filter or remove rows you dont need

Or use remove datarow if you know specific indexrows to remove

Cheers