Solution 1 shows you how to get an
output parameter from a Stored Procedure. But you already know how to do this as you asked a very similar question earlier that dealt with output parameters.
To get the return value you need still to add an appropriate parameter to the collection for
cmd
but this time it is a
Return Value, i.e.
cmd.Parameters.Add("@retValue", System.Data.SqlDbType.Int).Direction = System.Data.ParameterDirection.ReturnValue;
Then after you have executed the stored procedure you get the return value as you would any other parameter (which you already know how to do)
int retval = (int)cmd.Parameters["@retValue"].Value;
In cases like this the official documentation is a wonderful resource - I suggest you try it :
System.Data.SqlClient Namespace[
^]