ExecuteNonQuery and Stored Procedure

  • Thread starter Omkumar Enkannathan
  • 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??
 
W

William \(Bill\) Vaughn

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.
__________________________________
 
O

Omkumar Enkannathan

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.
__________________________________
 
M

Marc Scheuner [MVP ADSI]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top