Solved

ExecuteNonQuery returns double count

Posted on 2011-09-16
2
464 Views
Last Modified: 2012-08-14
If I run the following in VB.NET the return value of the record count is double the actual update in SQL Server.

cmd.CommandText = "update documents set IsVerified = 1 where  IsVerified= 0"
Dim ret As Integer = cmd.ExecuteNonQuery

The value of ret is double the actual records updated.

Additional Information.

In SQL Server when I run the update query the return messages are as follows.

(9 row(s) affected)

(9 row(s) affected)

It appears that the ExecuteNonQuery is returning the added value of Rows Affected reported by SQL Server.

If I run the select statement of records meeting the conditions I get 9 rows.
0
Comment
Question by:dbote
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 500 total points
ID: 36548705
Do you have any triggers on the table as the return value will include any rows updated by the trigger as well as the initial update
0
 
LVL 1

Author Closing Comment

by:dbote
ID: 36548727
Yes, actually that is exactly the case.

It is not my database so I was not thinking about triggers.  It makes perfect sense though.

Thank you!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

734 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