Velocity Reviews - Computer Hardware Reviews

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

Thread Tools

How to check for duplicate key violation?

Posts: n/a
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
Posts: n/a
Error Number 2627 for MS-SQL server is for the violation of Unique-Key

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

Gaurav Vaish

Reply With Quote

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? 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