Exception Number in VS2005

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Umljaw==?=

    #1

    Exception Number in VS2005

    How to I get the Exception Number (code) for a database related error?
    I get the following error and I need to catch it to display a custom message.

    System.InvalidC astException: Unable to cast object of type 'System.DBNull'
    to type 'System.Byte
  • =?Utf-8?B?Umljaw==?=

    #2
    RE: Exception Number in VS2005

    Never mind; i've figured it out as:

    ex is System.InvalidC astException

    "Rick" wrote:
    How to I get the Exception Number (code) for a database related error?
    I get the following error and I need to catch it to display a custom message.
    >
    System.InvalidC astException: Unable to cast object of type 'System.DBNull'
    to type 'System.Byte

    Comment

    • Ignacio Machin ( .NET/ C# MVP )

      #3
      Re: Exception Number in VS2005

      On Oct 3, 2:04 pm, Rick <R...@discussio ns.microsoft.co mwrote:
      How to I get the Exception Number (code) for a database related error?
      I get the following error and I need to catch it to display a custom message.
      >
      System.InvalidC astException: Unable to cast object of type 'System.DBNull'
      to type 'System.Byte
      Hi,

      There is no such a thing, You can know the problem by the Exception
      Type and the Message.
      In your case it;s clearly a casting issue

      Tip:
      try to use coalesce in the sql query

      Comment

      Working...