How to check for duplicate key violation?

Discussion in 'ASP .Net' started by EC, May 20, 2005.

  1. EC

    EC Guest

    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?
     
    EC, May 20, 2005
    #1
    1. Advertisements

  2. EC

    MasterGaurav Guest

    MasterGaurav, May 20, 2005
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ad
    Replies:
    4
    Views:
    978
  2. Replies:
    3
    Views:
    971
  3. Pete
    Replies:
    2
    Views:
    342
    Phlip
    Apr 15, 2006
  4. M P
    Replies:
    1
    Views:
    659
  5. John
    Replies:
    2
    Views:
    224
    Mike Brind
    Jul 8, 2006
Loading...

Share This Page