PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms Prevent duplicate value

Reply

Prevent duplicate value

 
Thread Tools Rate Thread
Old 02-06-2005, 06:19 AM   #1
mf_sina
Guest
 
Posts: n/a
Default Prevent duplicate value


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


  Reply With Quote
Old 04-06-2005, 02:06 AM   #2
Stoitcho Goutsev \(100\) [C# MVP]
Guest
 
Posts: n/a
Default Re: Prevent duplicate value

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.


--
Stoitcho Goutsev (100) [C# MVP]


"mf_sina" <mf_sina@yahoo.com> wrote in message
news:eEePiKzZFHA.3648@TK2MSFTNGP14.phx.gbl...
> 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
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off