473,699 Members | 2,579 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ExecuteNonQuery returning -1 (vb+asp.net+sql server 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.Execut eNonQuery())

--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 3016
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*******@gmai l.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.Execut eNonQuery())

--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
2097
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 table (first letter of temp table name = #) then the last thing I do is select * from #temptable. However Crystal can not see in the VB .net IDE any fields just the SP. If all I do is create the temp table and then do select * from #temptable I can...
1
2365
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. Can anyone help me how to do this Thanks in advance PS
3
1182
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 vb.net and sqlserver 2000 Thanks in advance....
0
1272
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 .Net 2003 standard edition. The install went fine and in the server explorer I can connect to all databases on my SQLserver 2000 MSDE, not to those made with SQLserver 2005 express, but this seems normal, isn't it?
3
1525
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
2518
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 for both of your reactions. Ken included the links, so it is clear which books he recommended (I will get them!) M.Posseth recommended "the complete MCSD self paced training kit" and "Programming Microsoft Visual Basic form Francesco Balena",...
5
1066
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 VB.NET and Back end SQLSERVER. Now he changed his mind set that he need that application in ASP.NET. My doubt is it possible to do the Inventory ERP in ASP.NET. The modules are Purchase, Shipping, Stock,POS, CRM and accounts. About Requirement:...
7
1804
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 (stores the customer picture and signature) tbl_InsuranceCompanies (stores the Insurance companies information) tbl_InsuranceType (stores the insurance type)
20
2285
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
2453
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 values from. For example, the XML file is meant to return the values from node"config2", because the "configoption" node's value is that. I'm extremely new to XML and the code that accesses it, but from what I could gather from materials read, I got...
0
8615
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9173
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9033
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8911
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6533
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5872
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.