If you have an option of disallowing duplicate table entries in your database then use that - what database are you using? You could then use Try, Catch to catch any exception that may be thrown if you try to entre a dup record.
If not you could use a SELECT sql command with a WHERE clause of the ID number you want to check for, if the sql select returns a record then the ID is already there if not then it is ok to insert data.
Stuart