After running a insert or update query against a SQLServer 2005 database, under what scenario (if at all) can this happen – SQLServer 2005 does not perform or fails to perform the insert / update, AND ALSO DOES NOT ‘THROW’ AN EXCEPTION?
Consider that we are running the insert or update query via a SqlCommand object. Also consider that the table against which insert or update query is being used, has
- identity fields
- fields which are not null,
- fields with appropriate data-types
- fields which are reference keys
- fields which have check constraints applied
- etc.
Please assume that in the update query, the ‘WHERE’ condition will find a recrod that needs to be updated.
Can we assume that after we do a SqlCommand.ExecuteNonQuery(), if a insert or update is not performed, then, an un-handled exception will ALLWAYS occur? Otherwise, we can assume that the insert or update query has been successful.
You can assume that an exception (SqlException) will be thrown UNLESS the INSERT/UPDATE includes a WHERE clause that doesn’t match any rows.