Geeks With Blogs

News


Dylan Smith ALM / Architecture / TFS

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 | Back to top


Comments on this post: SqlCommand.ExecuteNonQuery() changed behaviour??

# re: SqlCommand.ExecuteNonQuery() changed behaviour??
Requesting Gravatar...
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
Left by David on Dec 03, 2006 3:08 PM

Your comment:
 (will show your gravatar)


Copyright © Dylan Smith | Powered by: GeeksWithBlogs.net