Exception Number in VS2005

R

Rick

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.InvalidCastException: Unable to cast object of type 'System.DBNull'
to type 'System.Byte
 
I

Ignacio Machin ( .NET/ C# MVP )

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.InvalidCastException: 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top