asp_databases thread: return value, stored procedure, connection object
Message #1 by "joern saischek" <joern.saischek@c...> on Tue, 6 Jun 2000 16:32:1
|
|
Hi,
for performance reasons I would like to use the connection object to
execute my stored procedure (insert, no recordsets back).
on the other side I would like to get back an answer if the insert was
actually performed.
Do I really have to use the command object or the recordset object to get
my value (@returncode) or is there a way with the connection object?
Message #2 by "Cory Koski" <ckoski@w...> on Tue, 6 Jun 2000 11:47:02 -0400
|
|
if you want any sort of flexibility with Stored Procs, use the Command
object... it's quite useful.
Cory
----- Original Message -----
From: "joern saischek"
To: "ASP Databases" <asp_databases@p...>
Sent: Tuesday, June 06, 2000 4:00 PM
Subject: [asp_databases] return value, stored procedure, connection object
> Hi,
>
> for performance reasons I would like to use the connection object to
> execute my stored procedure (insert, no recordsets back).
>
> on the other side I would like to get back an answer if the insert was
> actually performed.
>
> Do I really have to use the command object or the recordset object to get
> my value (@returncode) or is there a way with the connection object?
>
>
Message #3 by Andrew Piper <pip@p...> on Tue, 6 Jun 2000 17:06:27 -0000
|
|
Hi,
Yep, if you look at Wrox - Beginning Visual Basic SQL Server 7.0 Chapter 10
it has the solution to your question.
It uses a return parameter from the stored procedure which you set up as
though you were passing params into the SP viz
objCMD.Parameters.Append objCmd.CreateParameter("@rc", adInteger, ad
ParamReturnValue)
In the SP you can do as follows
-- Declare Variables
DECLARE @rc INT
-- Do your action
-- Test the rowcount, if gt 0 action success
IF @@rowcount > 0
BEGIN
SELECT @rc = 0
RETURN @rc
END
ELSE
-- Action failed return a value
BEGIN
SELECT @rc = 1
RETURN @rc
END
Rgds
Pip
-----Original Message-----
From: joern saischek
Sent: 06 June 2000 01:00
To: ASP Databases
Subject: [asp_databases] return value, stored procedure, connection
object
Hi,
for performance reasons I would like to use the connection object to
execute my stored procedure (insert, no recordsets back).
on the other side I would like to get back an answer if the insert was
actually performed.
Do I really have to use the command object or the recordset object to get
my value (@returncode) or is there a way with the connection object?
|