Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to check for duplicate key violation?

Reply
Thread Tools

How to check for duplicate key violation?

 
 
EC
Guest
Posts: n/a
 
      05-20-2005
I get an SqlException caused by trying to insert a duplicate key into a
table. The user needs to be informed and asked to supply a new input. I
check the SqlException object and see these two properties:

ex.Number = 2627
ex.Message = "Violation of UNIQUE KEY constraint ..."

So is it safe to check the Number property against 2627 ? If not, what is
the proper way to check this exception?


 
Reply With Quote
 
 
 
 
MasterGaurav
Guest
Posts: n/a
 
      05-20-2005
Yes.
Error Number 2627 for MS-SQL server is for the violation of Unique-Key
Constraint.

Rules: The number is valid only for MS-SQL server.


Cheers,
Gaurav Vaish
http://mastergaurav.org
http://mastergaurav.blogspot.com
------------------------

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Batch Insert with duplicate key Felix Roberto Java 3 12-12-2006 07:23 PM
how to avoid inserting duplicate key to the table? jrefactors@hotmail.com Java 3 07-18-2005 08:41 PM
Catch duplicate primary key exeption ad ASP .Net 4 06-07-2005 11:32 AM
Replace Tab Key to Return Key (Enter Key) from Web Forms? M P ASP General 1 08-06-2004 08:32 AM



Advertisments