Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

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

 
Thread Tools Search this Thread
Old 08-09-2006, 05:59 PM   #1
Default ExecuteNonQuery returning -1 (vb+asp.net+sqlserver 2000)


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(,
@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



jzogg7272@gmail.com
  Reply With Quote
Old 08-09-2006, 07:46 PM   #2
=?Utf-8?B?QnJhZCBSb2JlcnRz?=
 
Posts: n/a
Default RE: ExecuteNonQuery returning -1 (vb+asp.net+sqlserver 2000)
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.


--
Brad

"Software is like melted pudding..."


"" wrote:

> 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(,
> @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
>
>



=?Utf-8?B?QnJhZCBSb2JlcnRz?=
  Reply With Quote
Old 08-09-2006, 09:40 PM   #3
jzogg7272@gmail.com
 
Posts: n/a
Default Re: ExecuteNonQuery returning -1 (vb+asp.net+sqlserver 2000)
I confirmed that after the proc was called and -1 was returned, the
record had been inserted.



jzogg7272@gmail.com
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows Media Player and ASP.NET (with VB code behind) jaanazam Software 2 08-28-2008 08:26 AM
The summary of cancelled Microsoft exams before March 2008 zhang Software 1 06-12-2008 04:03 AM
ASP.NET VB Using ItemDataBound to create textbox in datagrid rows. smi59550 General Help Related Topics 0 01-18-2008 07:42 PM
help me for SQL server 2000 and ASP.NET rishabhsethi General Help Related Topics 0 12-27-2007 10:19 AM
Computer Security aldrich.chappel.com.use@gmail.com A+ Certification 0 11-27-2007 02:11 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46