Select from following answers:- Add a parameter named @@RETURN_VALUE with Direction ParameterDirection.ReturnValue. Retrieve its value after executing the command.
- Execute the query using SqlCommand.ExecuteNonQuery and retrieve this method's return value.
- Add a parameter named @@IDENTITY with Direction ParameterDirection.Output. Retrieve its value after executing the command.
- All Above
To retrieve a stored procedure return value, you must add a parameter named @@RETURN_VALUE with Direction ParameterDirection.ReturnValue. Retrieve its value after executing the command.
The SqlCommand..ExecuteScalar method executes a query and returns the first column of the first row in the result set returned by the query. Because this stored procedure does not execute a query, you should not use this method.
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. This would return 1 for this stored procedure (1 row added), not the value of the identity column.
Show Correct Answer
Source: MeasureUp.Com | |
Alert Moderator