Exception Handling

  • Thread starter Thread starter shimonsim
  • Start date Start date
S

shimonsim

Hi
Is there some general way to figure out reason for SqlException.
1) constraints: PK, FK or other - may be it is possible to find out with on?
like in case of triggers and constraints
2) missing objects
3) no connections, identity problem or lost connection with server.

Thanks
Shimon
 
Examine the Exception.toString...it will give you a lot of information

Try

Catch ex as sqlException
Debug.Assert(false, ex.ToSTring)

End Try

HTH,

Bill
 
William Ryan said:
Examine the Exception.toString...it will give you a lot of information

Try

Catch ex as sqlException
Debug.Assert(false, ex.ToSTring)

End Try

But the message gets a "sprintf" with object names, so it can be difficult
to code against.
If you want something easier to code for, use the SqlException.Number.
The Number and Message are both stored in master.dbo.sysmessages.


David
 
Agreed. If the goal is to respond programmatically, then ex.ToSTring is
not the way to go for sure. If you are trying to understand what's
happening while debugging..then err number and all probably don't give you
everything you need quite as easily.

Either way though, you have an excellent point.

Bill
 
Back
Top