I have used Linq to check duplicates in a column of a datatable. Please see below code.
Dim duplicates = dt.AsEnumerable() _
.GroupBy(Function(i) i.Field(Of String)("COLUMNNAME")) _
.Where(Function(g) g.Count() > 1) _
.Select(Function(g) g.Key)
For Each ed In duplicates
isValid = False
Next
But the problem if there are two or more empty fields, it will take them as duplicates. As the field is optional, it only needs to check if there is data.
Could anyone tell me how to find duplicates in a column in datatabe. Just from a column. It does NOT need to be Linq. I just put the code I have if it can do the job with a small tweak. Thanks a lot.