ExecuteNonQuery and Stored Procedure

  • Thread starter Thread starter Omkumar Enkannathan
  • Start date Start date
O

Omkumar Enkannathan

Hai All,

I need some help. I am calling a stored procedure using ExecuteNonQuery (I
am not expecting any results back from the stored procedure).

When there is something wrong with the stored procedure execution, the
procedure returns different error codes ( I call the RETURN() method ). How
do I capture these return values after calling the ExecuteNonQuery() method?

For example:-

my stored procedure is like...

CREATE PROC myproc...
....
begin
/* do something */
/* oops an error*/
goto error
.....

error
return(-11) //if -11 the insertion failed

end

***********************************

How do I retrieve the -11??
 
Perhaps my article on handling parameters might help.
http://www.betav.com/msdn_magazine.htm

--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Thank you for your quick response. That was very helpful

--
Om.
William (Bill) Vaughn said:
Perhaps my article on handling parameters might help.
http://www.betav.com/msdn_magazine.htm

--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
I need some help. I am calling a stored procedure using ExecuteNonQuery (I
am not expecting any results back from the stored procedure).

When there is something wrong with the stored procedure execution, the
procedure returns different error codes ( I call the RETURN() method ).

Maybe you want to change this to call RAISEVENT in your stored proc,
so you'll get a SqlException in your C# code, to handle error
conditions easily and consistently with your other code....

Marc

================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
Back
Top