Dylan Smith

Architecture / Agile / TDD

  Home  |   Contact  |   Syndication    |   Login
  37 Posts | 0 Stories | 9 Comments | 30 Trackbacks

News



Archives

Blogs I Read

I was just writing some wrapper code for our database access layer, and I noticed that ExecuteNonQuery seems to be behaving differently than I thought it behaved.  It says it returns the count of the records affected.  I had thought that if you were executing multiple queries in your stored proc, it would return the records affected by only the last query.  However, it appears to be returning the sum of the records affected from all queries.

Is this something that has changed in .Net 2.0, or maybe in SQL Server 2005?  It doesn't really affect us that much, but if it has in fact changed I can see that breaking alot of peoples code where they were performing a check against the return value to ensure it was as expected.

posted on Monday, July 17, 2006 11:43 AM

Feedback

# re: SqlCommand.ExecuteNonQuery() changed behaviour?? 12/3/2006 3:08 PM David
You are correct, it returns the sum of all affected records when doing multiple queries in a stored proc. I thought it was always this way, but I was waned mostly on 2.0 so I could be wrong

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: