ExecuteNonQuery returning -1 (vb+asp.net+sqlserver 2000)

J

jzogg7272

In my code I am executing a stored procedure to do a single row insert.
I check the return value of the execution and I am getting -1, whereas
a few weeks ago it was returning 0. Actually, I found that all of my
insert stored procs are returning -1. The stored proc/insert statement
is still executing successfully but the return code is different. If I
execute the procedure from SQL Query Analyzer with the same params, it
shows a return code of 0. But -1 is return back when it is executed
from code. Anyone know why?
FYI - I recently promoted 3 new stored procs; completely unrelated to
this functionality. That is all that has "changed" recently.

Here is some of the code:

nReturn = CInt(cmd.ExecuteNonQuery())

--Stored proc:

Procedure dbo.AddVehicle
/* Param List */
@license varchar(8),
@model_id int,
@year smallint,
@vin varchar(20),
@bar_code varchar(6),
@gas_card varchar(4)

AS
SET NOCOUNT ON

INSERT INTO Vehicles ( license, model_id, [year], vin, bar_code,
gas_card )
VALUES ( @license, @model_id, @year, @vin, @bar_code, @gas_card )

SET NOCOUNT OFF
 
G

Guest

According to the .NET v1.1 documentation...

For UPDATE, INSERT, and DELETE statements, the return value is the number of
rows affected by the command. For all other types of statements, the return
value is -1. If a rollback occurs, the return value is also -1.
 
J

jzogg7272

I confirmed that after the proc was called and -1 was returned, the
record had been inserted.
 

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

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top