sqlexception - PK violation

  • Thread starter Thread starter Roel
  • Start date Start date
R

Roel

Hello

When I try to insert a record in database with a PK that already exists I
receive the error:
The changes you requested to the table were not successful because they
would create duplicate values in the index, primary key, or relationship.
Change the data in the field or fields that contain duplicate data, remove
the index, or redefine the index to permit duplicate entries and try again.

Does anybody knows how I can handle this exception ?

Many thx

Roel
 
Not sure what you want, what is the PK for? it did its work, you can not
insert duplicate record.
 
Roel,

I would check the Number property of the SqlException to check for the
specific error (there should be a unique error code for that error).

Hope this helps.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top