Question Checking existence of list item in sql database

asest

Member
Joined
Aug 25, 2010
Messages
7
Location
Kent, UK
Programming Experience
1-3
Hi

I am trying to check where an item in my array list exists in the database.
The list would have already been created at an earlier stage.
Now that some items may have been removed from the database, I wish to check the list against that database before removing the items, from the list, which are no longer in the database.

The following code removes all items from the list rather than just each one which doesnt exist.

While rdr.Read
'look for and remove errors that don't exist in
For Each listitem In mylist
If Not listitem.ID = rdr("ID") Then
mylist.Remove(listitem)
End If
Next
End While

Any thoughts? I am sure this can't be too far away.
 
Okay,

clearly if one is to find a record that doesn't exist in a database then the check can not be done inside the sql reader itself.

Update to my query...

How does one loop through a list to check against a db?
 
While rdr.Read
If mylist.contains(rdr("ID").tostring()) Then
mylist.Remove(rdr("ID").tostring())
End If
End While

Sorry, Im not sure with this one.
 
Back
Top