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!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.