Dear all,
i have a code block that tries to insert into the datatabase for adding new client. of course the client table has a unique constraint on the clientid Column.

now when trying to execute the code of adding, there are two exceptions that might happen

1 - no connection to the sqlserver

2 - trying to add a client with a duplicated ID ( which will not be allowed by the datatabase) .

in my catch block i need to display a different message in each case.
( for example : when the sql is not found , msgbox("please check your connection") and in the other case (msgbox("this client already exists !!")


right now i am using a single catch ex as exception

which is very general and catches all exceptions and just display stupid msgbox("Unknown error while adding").

i do understand how exception catching work ( from the specific to the genreal bla bla bla .. ) what i need to know is the name of the exception object that is returned when a duplicated row is violating a unique index in sql server.


sorry for writing all this text, and thank you for reading it

BST RGDS

Maged A. Reda