What values ExecuteNonQuery
returns if update
, insert
, delete
are success, at the same time when they were failed?
ExecuteNonQuery
returns the number of rows affected.
ExecuteNonQuery
For UPDATE, INSERT, and DELETE statements, the return value is the number of
rows affected by the command.
You might find the following reference material handy, SqlCommand.ExecuteNonQuery
Method .
To quote directly:
Executes a Transact-SQL statement against the connection and returns the number of rows affected.
So...
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. 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. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1.
So either the number of rows affected by the command(s) or -1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With