Re: Return value from Stored Procedure
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Fri, 6 Apr 2007 12:54:22 -0400
I suspect that SQL Express has NOCOUNT off by default, at least on your
installation.
PS. Since it appears from the snippet of the stored procedure you showed in
your OP that you are not retrieving a recordset back from your procedure,
you should specif adExecuteNoRecords in the <execute options> argument of
your Execute call. Actually, you should get rid of the rsID stuff totally:
why make ADO construct a recordset when you are not retrieving records?
PPS. You should avoid @@IDENTITY, using Scope_identity instead. It will
prevent unexpected results, especially if your table has a trigger on it.
Light wrote:
After playing with the code for awhile, especially with this
Set rsID = rsID.NextRecordset
I found out that on the Sql Server 2000, I need this line, and yet on
the Express, I can do without it, what gives?
TIA
Bob Barrows [MVP] wrote:
1. When you execute a query in Query Analyzer, did you ever notice
those "x rows affected" messages? Well, it's not just QA that those
messages get delivered to. They get returned to ADO as recordsets
... 2. SQL Server does not return the output or return parameter values
until all recordsets generated by the procedure are consumed
Setting NOCOUNT to off prevents those extra resultsets from being
generated and returned.
Light wrote:
Hi Bob,
That does it, but why?
Thanks a billion, you just save my life:).
Bob Barrows [MVP] wrote:
Light wrote:
CREATE Procedure NewCompany
(
@varCompanyName varchar (50) = null,
@RETURN_VALUE int OUTPUT
)
As
You need to add "SET NOCOUNT ON" to this procedure - right here as
a matter of fact.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
.
- References:
- Return value from Stored Procedure
- From: Light
- Re: Return value from Stored Procedure
- From: Bob Barrows [MVP]
- Re: Return value from Stored Procedure
- From: Light
- Re: Return value from Stored Procedure
- From: Bob Barrows [MVP]
- Re: Return value from Stored Procedure
- From: Light
- Return value from Stored Procedure
- Prev by Date: Re: Return value from Stored Procedure
- Next by Date: Re: ADO record update
- Previous by thread: Re: Return value from Stored Procedure
- Next by thread: Re: Error No 3712; Operation has been cancelled by the user
- Index(es):
Relevant Pages
|
|