Results 1 to 2 of 2

Thread: How to distniguish between Sql internal exceptions ??

  1. #1

    Thread Starter
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    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

  2. #2

    Thread Starter
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    Re: How to distniguish between Sql internal exceptions ??

    anyone ???

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width