Function Return inside Store Procedure

  • Thread starter Thread starter Daniel Caetano
  • Start date Start date
D

Daniel Caetano

Hi all, i have a store procedure that i use the return function . Ex.
create procedute XX as
(statement...)
if @@error <> 0
return 1
else
return 0 .

Inside the vb net i wnat to call that procedure and retrieve that value
returned. I´m using command. Is that possible? How can i do it? Or i must to
create an output variable in my sp?
Thanks
 
Daniel,

You could use an Output variable, or use RAISERROR keyword within Stored
Procedure along with a custom error (see sp_addmessage in Books Online) and
catch the error in your application (see ADODB.Errors Collection).

Cheers,
Neil
 
Hi,

IIRC, you can add a parameter with ParameterDirection.Return to the command
that's calling the storedprocedure. Retrieving the return value can then be
done by reading the value of the passed parameter.

Erik
 
Hi,

IIRC, you can add a parameter with ParameterDirection.Return to the command
that's calling the storedprocedure. Retrieving the return value can then be
done by reading the value of the passed parameter.

Erik


Hi,
and do you know a way to get the output of the PRINT statements from the
SP?

Thanks
Sunny
 
Hi,

Capturing the output from print statements will be somewhat more difficult.
IIRC ADO had a special collection that contains these messages in its
command object. Can't find (or overlooked) that same functionality in .NET.
As the output gets to stdout when you call the sp from the console, you
might want to try to redirect standard output to a stream and read the
results from there.
You'll have to do some more digging work on this !

Erik
 
Back
Top