Is it possible to get the errornumber in C#? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Is it possible to get the errornumber in C#?

de paashaasde paashaas Posts: 4Member
I have made a C# project and i put try en catch around the functions to do the error-handling. When an error is thrown i call a function, with Exception exc as an argument, to get the same errorpage every time an error is thrown.
In visual basic it was possible to get the number of the error that was thrown by: Err.Number
My question is whether this is possible in C# too? And how do you do this? Because the Exception exc hasn't got a property to do it.




  • Vikas_matVikas_mat Posts: 1Member
    Yes, you can get the errorcode from the Exception, but you have to use innerexception except the Base Exception.

    some code here....
    catch(System.Data.SqlClient.SqlException ex)
    MessageBox.Show("this is Sql Exception");
Sign In or Register to comment.