SQl Server SP errors in C#
-
I'm executing SQL Server stored procedures from C# and I'm having problem figuring out a few things. My stored procedure have become pretty complex and I need to check whether the SP executed successfully or not. What should I do? Should i use a RAISEERROR in the SP, should i use RETURN or should i use SELECT? Once i find out in my C# code that an error has occurred, i want to display the appropriate message to the user. How do I do this? Would i have to enclose the C# code to execute the SP in a try-catch block? Thanks in advance guys!
-
I'm executing SQL Server stored procedures from C# and I'm having problem figuring out a few things. My stored procedure have become pretty complex and I need to check whether the SP executed successfully or not. What should I do? Should i use a RAISEERROR in the SP, should i use RETURN or should i use SELECT? Once i find out in my C# code that an error has occurred, i want to display the appropriate message to the user. How do I do this? Would i have to enclose the C# code to execute the SP in a try-catch block? Thanks in advance guys!
I'd return an error code, and have it map to an enum in the C# for all possible errors, or success.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog