How to remove rows that have completed iteration from a DataTable help

@22222222asas

As the Data in the datatable is going to change after Removing data from datatable.It will throw an error that “Collection is modified” using for each

Use the linq Query instead of it after reading the excel

dtInput = dtInput.AsEnumerable().GroupBy(Function(row) row.Field(Of String)("ColumnName")).Select(Function(group) group.First()).CopyToDataTable()

Hope it helps!!

1 Like