我有一個存儲過程返回一個學生是否被鎖定或不:返回從存儲過程的值的方法
RETURN @isLocked
我執行這樣的存儲過程:
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));
}
我可以將這個「ISStudentLocked」方法稱爲布爾方法嗎?像這樣: public static bool IsLockedOut(string studentName) { return(IsUserLocked(studentName,Util.LockoutDays)== 1); } – user793468 2012-07-06 22:18:19
當然,不明白爲什麼不。 – rossipedia 2012-07-06 22:38:25
我得到一個「非靜態字段,方法或屬性'Student.Models.Authorization.IsStudentLocked(字符串,int)需要對象引用」錯誤 – user793468 2012-07-09 14:51:43