Getting return value from stored procedure in C#

Mehrdad makes some good points, but the main thing I noticed is that you never run the query

SqlParameter retval = sqlcomm.Parameters.Add("@b", SqlDbType.VarChar);
retval.Direction = ParameterDirection.ReturnValue;
sqlcomm.ExecuteNonQuery(); // MISSING
string retunvalue = (string)sqlcomm.Parameters["@b"].Value;

Leave a Comment