C
Christiaan van Bergen
Hi all,
I want to trap a Primary Key Constraint Violation. This is an exception of
the type System.Data.SqlClient.SqlException that is thrown whenever I insert
a record with an already existing key in the database.
Is there a way to trap this specific exception?
The only way I can come up with is to check the Exception.Message on the
presence of the text "Violation of PRIMARY KEY".
There must be a better way.
Please advice
Regards
Christiaan
I want to trap a Primary Key Constraint Violation. This is an exception of
the type System.Data.SqlClient.SqlException that is thrown whenever I insert
a record with an already existing key in the database.
Is there a way to trap this specific exception?
The only way I can come up with is to check the Exception.Message on the
presence of the text "Violation of PRIMARY KEY".
There must be a better way.
Please advice
Regards
Christiaan