You need to query the database and check for an existing record. Or you can just run the insert command and catch the returned exception that tells you that there is a violation of the primary key. I'd recommend running a check query first instead of letting the insert fail. My philosophy is that if a key violation is an expected condition then it's not an exception, so check for it.
-
Peter