Removing data row in a for loop

image
image


Hi, I’m trying to removing the row in data datable where email matches the email in arr1. But i keep getting this error how can I solve it ?
test.xaml (12.5 KB)

I forget to put the if : item.Equals(CurrentRow.Item(“Email”)) then run : remove data row, although i add in, i still get same error

Hey Wei,

The error basically states that you cannot proceed the operation in for loop becase you modified the datatable (removed some values).

Try using this linq query:
dt1 = dt1.AsEnumerable().Where(Function(row) Not arr1.Contains(row(“Email”).ToString)).CopyToDataTable

image

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