locked
How do I retrieve RAISERROR() messages (no exceptions raised) from within ADO.NET? RRS feed

  • Question

  • Hi,

    I have been writing a few stored procedures returning error messages explaining the reason why something did not work as expected using RAISERROR('Some explanation.', 11, 1).

    Is it possible to retrieve these messages/state values from within a client connected via ADO.NET?

    Your help is appreciated!


    Vote here for a Microsoft Connect feedback channel on Windows - and win a better Windows!

    Tuesday, October 11, 2011 3:54 PM

Answers

  • These will trigger a SqlException in ADO.NET if level is 10 or higher.  So place a try catch around your ADO.NET code and catch the SqlException, it will have the message and error code and state.
    Matt
    Tuesday, October 11, 2011 4:50 PM