简体   繁体   中英

Can I suppress messages that are sent using RAISERROR in C#

We currently have an application in ASP.NET and using SQL Server. We have used RAISERROR , whenever and wherever required in our stored procedures.

Now the client wants the real SqlException to be captured in our try catch, and not the one that is printed in SQL Server.

Is it possible? If yes then can anyone let me know please.

Thanks and regards.

Thanks Jimmy for answering that, also I would like to comment on the code. My SQL stored procedure was like

CREATE STORED PROCEDURE ------------
----------
------
BEGIN TRY
UPDATE table_name
 SET column1=value1,column2=value2,...
 WHERE some_column=@some_value
END TRY
BEGIN CATCH
RAISEERROR(500001,1,16)
END CATCH

So either the rows where not updated, or there was some conversion error, but irrespective of whatever, the user will be displayed only what was described in the RAISEERROR. I just gave a select @@ERRORMESSAGE after the RAISEERROR and that allowed me to capture details. So when I got the result back to my application in .NET, along with the RAISEERROR, it also gave me the details of @@ERRORMESSAGE, this helped me out. Thanks all again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM