Home All Groups Group Topic Archive Search About

Checking unique constraint from application

Author
4 Aug 2006 4:40 PM
gary7
Hi Folks,
I have a unique column contraint (Indexed, non-clustered, Not-Null, Not
PK, the column value is nvarchar type(50)) on a dataset. I am trying to
figure out how to check for the unique value before submitting update
back to database.

I want to trap the user entry if it violates the constraint, and supply
a message dialog so the user can make corrections before re-submitting
the update.

The message only needs to let the user know that the textbox entry they
have attempted to save is already in the database, and they should try
some other unique entry.

So far, I haven't figure out how to raise the error, or trap it for
processing at the application level.
However,  the table simply does not save the violating entry; nor does
it return an error, so if a user does supply an entry that is not
unique, they will not recieve any message indicating such, and it is
not apparent until they try to look-up this new, redundant entry --
which isn't in the table.

TIA

Gary

Author
5 Aug 2006 7:54 PM
--CELKO--
>> I want to trap the user entry if it violates the constraint, and supply a message dialog so the user can make corrections before re-submitting the update. <<

Why?  It would be better to use the front end to format the input into
a standard format, submit it to the DB and catch the error .  If you
have the same code in the DB and the front end, then you have to update
both fo them and keep them in synch.
Author
7 Aug 2006 2:14 PM
gary7
Would you mind demonstrating what you have said?  An example would be
quite helpful!

Thanks for your time!
Gary

--CELKO-- wrote:
Show quote
> >> I want to trap the user entry if it violates the constraint, and supply a message dialog so the user can make corrections before re-submitting the update. <<
>
> Why?  It would be better to use the front end to format the input into
> a standard format, submit it to the DB and catch the error .  If you
> have the same code in the DB and the front end, then you have to update
> both fo them and keep them in synch.

AddThis Social Bookmark Button