I am looking for an effective way to search through a dataset to find out if an element exists. I have an arraylist of ~ 6000 elements, and I need to determine which one does not exist in the data set by comparing each element in the array with the data in a specific column of the data set.
I tried to skip every item in the dataset for each in an arraylist, but that took forever. Then I tried to use the RowFilter method. None of them look effective. Any help is greatly appreciated as you can say that I am not a very programmer ...
Example:
Dim alLDAPUsers As ArrayList
alLDAPUsers = clsLDAP.selectAllStudents
Dim curStu, maxStu As Integer
maxStu = alLDAPUsers.Count
For curStu = 0 To maxStu - 1
Dim DomainUsername As String = ""
DomainUsername = alLDAPUsers.Item(curStu).ToString
Dim filteredView As DataView
filteredView = dsAllStudents.Tables(0).DefaultView
filteredView.RowFilter = ""
filteredView.RowFilter = "szvausr_un = '" & DomainUsername & "'"
Dim returnedrows As Integer = filteredView.Count
If returnedrows = 0 Then
'' Delete the user...
End If
Next
source
share