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
Solved

ExecuteNonQuery returns double count

Posted on 2011-09-16
2
455 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
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

829 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