![]() |
|
|
|||||||
![]() |
ASP Net - ExecuteNonQuery returning -1 (vb+asp.net+sqlserver 2000) |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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 |
|
|
|
|
#2 |
|
Posts: n/a
|
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?= |
|
|
|
#3 |
|
Posts: n/a
|
I confirmed that after the proc was called and -1 was returned, the
record had been inserted. jzogg7272@gmail.com |
|
![]() |
| Thread Tools | Search this Thread |
|
|
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 |