Function Return inside Store Procedure

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
 
N

Neil Woodvine

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
 
E

Erik Tamminga

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
 
S

Sunny

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
 
E

Erik Tamminga

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
 

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