a) SqlCommand.ExecuteNonQuery
is used for update, insert and delete operations.
Besides the fact that by using ExecuteNonQuery
instead of ExecuteReader
we automatically know there won’t be any query results returned, are there some other benefits/reasons why ExecuteNonQuery
should be used?
b) Similarly, if we want a database operation to return a single value, we should use ExecuteScalar
instead of ExecuteNonquery
,where with the latter result would be returned via SqlParameter
. Is there any particular reason why we should prefer ExecuteScalar
over ExecuteNonQuery
?
thanx