473,405 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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

Aug 9 '06 #1
2 2996
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..."
"jz*******@gmail.com" 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(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

Aug 9 '06 #2
I confirmed that after the proc was called and -1 was returned, the
record had been inserted.

Aug 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Paul M. | last post by:
Hi, I have a Crystal Report that I want to have use as its datasource a SQLServer 2000 stored procedure, basically the sp would do several selects to insert data from several tables into 1 temp...
1
by: PS | last post by:
I want to extract an image from sqlserver 2000 table and display it in picture box in vb.net form using ado.net and vb.net The image in the sql server 2000 table is stored in 'image' datatype. ...
3
by: prabhu | last post by:
Hi all, For all these i am a vb programmer and now our company is planning to go with vb.net and sqlserver 2000. Pls suggest me some good ebooks for beginners and as an advanced programming for...
0
by: Alain \Mbuna\ | last post by:
Hi to all. After working a while with visual basic express 2005 and SQLserver 2005 express, mainly to learn the vb language and to take my first steps with ADO.net, I decided to buy Visual Basic...
3
by: mokles | last post by:
Hello all, I want to subscribe to some magazines for asp.net and vb.net development. Does anyone know what will be best one to subscribe for this purpose? Thanks a lot. -Mokles
6
by: John | last post by:
I am looking for VB.Net books which provide a lot of exercises (preferrably with all the answers worked out on CD). In earlier reactions Ken Tucker and M.Posseth recommended a few books. Thanks...
5
by: suresh | last post by:
Our Team need to Develop one application In inventory. The objective is need to develop a application in VB.NET. For that i am doing SRS. While starting the SRS Customer need that application IN...
7
by: Niyazi | last post by:
Hi, I am developing small insurance application using VB.NET and SQL server 2000. My tables in SQL server are: tbl_Customer (stores the custmer information) tbl_CustImage ...
20
by: weight gain 2000 | last post by:
Hello all! I'm looking for a very good book for an absolute beginner on VB.net or VB 2005 with emphasis on databases. What would you reccommend? Thanks!
2
by: XML Beginner | last post by:
I have an XML file that contains values that my application needs, so it knows which database to connect to. It also contains a configuration option so that I can specify which node to return...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.