Perhaps you’re looking for ExecuteScalar instead? That’s appropriate for – say – fetching a count. If a rollback occurs, the return value is also -1. For all other types of statements, the return value is -1. When a trigger exists on a table being inserted or updated, the return value includes the number of rows affected by both the insert or update operation and the number of rows affected by the trigger or triggers. No, that indicates that it affected no rows.įrom the docs for SqlCommand.ExecuteNonQuery (emphasis mine):įor UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. If you want to do an UPDATE or DELETE, then you can do an ExecuteNonQuery() and that will show how many rows were affected. It is called ExecuteNonQuery because you want something to execute that is not a query. You shouldn’t execute a SELECT with an ExecuteNonQuery(). If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible. Please note that all the answers may not help you solve the issue immediately. Thank you for visiting the Q&A section on Magenaut.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |