Rückgabe eines Wertes von einer gespeicherten Prozedur an eine Methode
Ich habe eine gespeicherte Prozedur, die zurückgibt, ob ein Student gesperrt ist oder nicht:
RETURN @isLocked
Ich führe diese gespeicherte Prozedur wie folgt aus:
public int IsStudentLocked(string studentName, int lockoutTime)
{
SqlConnection connObj = new SqlConnection();
connObj.ConnectionString = Util.StudentDataInsert();
connObj.Open();
SqlCommand comm = new SqlCommand("uspCheckLockout", connObj);
comm.CommandType = CommandType.StoredProcedure;
comm.Parameters.Add(new SqlParameter("@Studentname", studentName));
comm.Parameters.Add(new SqlParameter("@LockoutTime", lockoutTime));
comm.ExecuteNonQuery();
connObj.Close();
//How can I return the @isLocked value below?
return ((int)(@isLocked));
}