Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# SQL-Server
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
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 23-Jan-13 4:42am
Edited 24-Jan-13 4:25am
jibesh at 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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Have a look at these articles you may get clear picture how to handle a try catch in sql.

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 595
1 OriginalGriff 295
2 CPallini 210
3 PIEBALDconsult 150
4 Fredrik Bornander 140
0 OriginalGriff 5,835
1 Sergey Alexandrovich Kryukov 5,263
2 CPallini 4,750
3 George Jonsson 3,227
4 Gihan Liyanage 2,487

Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 24 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100