Prevent duplicate value

  • Thread starter Thread starter mf_sina
  • Start date Start date
M

mf_sina

Hi everyone!

How can i prevent users from entering a duplicated customername in a vb .Net
form?
the form is already connectod to an access database (*.mdb)
although i set the field customername as primary key from microsoft access
but this isn't the solution.
i want to prompt user: This customer name is already Registered. Please
enter another one

any solutions are welcomed.
Best regards
 
mf_sina,

It depends on the structure of the application. I believe that the right
place for that is when you submit the data to the database. If the filed you
want to verify is a primary key the update will fail and you can go ahead
and give the user a chance to change the name. You can probably use the
Validating event and run a query against the user name when the focus lieve
the field, but keep in mind that in general there are chances of multi-user
access to the database, so if you verify at the moment user enters the
username field there are chances that at the moment you submit data this
name is already taken. So, my suggestion is to try to update the database
and the operation fails then give the user chance to fix the problem.
 
Back
Top