Select from following answers:- Execute the query using SqlCommand.ExecuteScalar and retrieve this method's return value.

- Add a parameter named "0" with Direction ParameterDirection.Output. Retrieve its value after executing the command.
- Add a parameter named @@RETURN_VALUE with Direction ParameterDirection.ReturnValue. Retrieve its value after executing the command.
- All Above
The SqlCommand.ExecuteScalar method executes the query and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.
The SqlCommand.ExecuteNonQuery method executes a Transact-SQL statement against the connection and returns the number of rows affected. 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 - like the one given - the return value is -1. This is not the desired result.
Show Correct Answer
Source: MeasureUp.com | |
Alert Moderator