[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ExecuteNonQuery return wrong value .NET 2.0

Posted on 2007-10-12
2
Medium Priority
?
615 Views
Last Modified: 2013-12-17
I have a stored procedure that deletes a single record (based on unique id)  When I run this from query analyzer it returns the out param as 1.   When I call this from .NET ExecuteNonQuery(cmd) it return a 19 which by definition is 19 records affected.  I have verified things by putting a new, single record in and deleting it via sql analyzer, then entering a single record and trying to delete it from ExecuteNonQuery.  It deletes but the return value is wrong and causes the rest of the app (which is expecint a 1) to cough.  Thougts?
0
Comment
Question by:mbowles
2 Comments
 
LVL 16

Accepted Solution

by:
McExp earned 500 total points
ID: 20067458
ExecuteNonQuery returns the number of rows affected if you want to handle the return value you need to add a parameter to the Command with a Direction of ReturnValue
0
 

Author Comment

by:mbowles
ID: 20067521
Turns out when I looked at the teamates sp it was usinga  return param value that needed to be capture and not a row affected count.  Switched to executescalar and all is well!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question