|
-
Apr 27th, 2006, 11:34 AM
#1
Thread Starter
Frenzied Member
How to distniguish between Sql internal exceptions ??
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
-
Apr 28th, 2006, 03:53 PM
#2
Thread Starter
Frenzied Member
Re: How to distniguish between Sql internal exceptions ??
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|