Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 483
  • Last Modified:

ExecuteNonQuery returns double count

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
dbote
Asked:
dbote
1 Solution
 
Paul JacksonCommented:
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
 
dboteAuthor Commented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now