Click here to Skip to main content
15,904,348 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I have a question, I have a stored procedure in sqlserver the return 2 variables, in this stored procedure I try catched error, so for the C# this procedure never exit with error.
I can use
C#
ERROR_NUMBER(),ERROR_SEVERITY(), ERROR_STATE(),ERROR_PROCEDURE(), ERROR_LINE(), ERROR_MESSAGE(); 

but I don't know if I have same errors, so I don't know what is the best way manage this situation...


A little improve: I know exactly how to catch error in t-sql and in C#, the problem is how to pass all the information that I catch in sql through C#, for example, without error the SP return 2 columns, but with error it return for example 5 columns, and I don't know a priori
Posted
Updated 24-Jan-13 4:25am
v3
Comments
Jibesh 24-Jan-13 15:28pm    
what are you trying to do here? you want return 5 Columns when error comes or it returns 5 columns when error comes and you wont want that? is that true? can you elaborate your question.

or when a error occurred in a SP you want that information to be handled and passed to your C# code to display at user side? if that was the case instead of putting exception inside the SP why dont you handle SQLException/exception in your C# code.

1 solution

Have a look at these articles you may get clear picture how to handle a try catch in sql.
article-handling-sql-server-error[^]
http://msdn.microsoft.com/en-us/library/ms175976.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900