How to Reset RAISEERROR in nested sps

  • Thread starter Thread starter Mart via .NET 247
  • Start date Start date
M

Mart via .NET 247

(Type your message here)
I am calling an sp from ADO.NET, and almost everything is fine:-). The ADO.Net code has a try catch block for SqlException.The sp calls another sp, which may call RAISERROR under acertain condition. When this happens the top level sp reads thecode returned to it and carries out appropriate action -however, this does not prevent the SQLException (generated bythe lower level sp) firing in the ADO.NET code when the upper spreturns to it.

Is it possible to reset the exception/RAISEERROR in the top levelsp, to prevent the ADO.NET SqlException firing.

Note that removing the RAISEERROR from the lower level sp is notan option, as this sp is required to be called direct fromADO.NET code elsewhere in the program.

Thoughts please.
 
The behavior of RAISERROR depends on the severity level assigned to
it, which you say you can't control in the stored procedure itself.
Once the error returned to the client, you can't do anything other
than deal with it in your SqlException handler. You can ignore
individual SqlError objects within the SqlErrorCollection simply by
having an empty catch block based on the SqlError.Number (or
whatever). There is sample code in the Help file that shows how to
work with the various collections and objects.

--Mary
 
Back
Top