468,784 Members | 1,557 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,784 developers. It's quick & easy.

Function Return inside Store Procedure

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. Im using command. Is that possible? How can i do it? Or i must to
create an output variable in my sp?
Thanks
Jul 21 '05 #1
4 1579
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

"Daniel Caetano" <dc******@ig.com.br> wrote in message
news:Oz*************@TK2MSFTNGP12.phx.gbl...
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. Im using command. Is that possible? How can i do it? Or i must to create an output variable in my sp?
Thanks

Jul 21 '05 #2
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

"Daniel Caetano" <dc******@ig.com.br> wrote in message
news:Oz*************@TK2MSFTNGP12.phx.gbl...
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. Im using command. Is that possible? How can i do it? Or i must to create an output variable in my sp?
Thanks

Jul 21 '05 #3
In article <ce**********@news3.tilbu1.nb.home.nl>,
ne********@NeOtammiSnPgAaM.nl says...
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
Jul 21 '05 #4
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

"Sunny" <su***@newsgroups.nospam> wrote in message
news:eU**************@TK2MSFTNGP10.phx.gbl...
In article <ce**********@news3.tilbu1.nb.home.nl>,
ne********@NeOtammiSnPgAaM.nl says...
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

Jul 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Rajesh Garg | last post: by
1 post views Thread by Hugo Lefevre | last post: by
4 posts views Thread by Daniel Caetano | last post: by
14 posts views Thread by James Thiele | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
2 posts views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.