我得到一個錯誤,當我嘗試更新我的紀錄過程或函數預計未供給
過程或函數
(sp_UpdateEmp)
預計未供給
這裏(@dateofbirth)
參數是我的函數參數
public void Updatedata(Bussinessobject.BO EBAL)
{
objconn = new SqlConnection(connectionstring);
if (objconn.State != ConnectionState.Open)
try
{
objconn.Open();
objcommand = new SqlCommand("sp_UpdateEmp", objconn);
objcommand.CommandType = CommandType.StoredProcedure;
objcommand.Parameters.AddWithValue("@id", EBAL.id);
objcommand.Parameters.AddWithValue("@fname", EBAL.fname);
objcommand.Parameters.AddWithValue("@lname", EBAL.lname);
objcommand.Parameters.AddWithValue("@address", EBAL.address);
objcommand.Parameters.AddWithValue("@phone", EBAL.phone);
objcommand.Parameters.AddWithValue("@birthdate", EBAL.birthdate);
objcommand.Parameters.AddWithValue("@hiredate", EBAL.datehire);
objcommand.Parameters.AddWithValue("@gender", EBAL.gender);
objcommand.ExecuteNonQuery();
}
catch
{
throw;
}
}
我的心理調試能力告訴我,你應該使用''@dateofbirth'' – SWeko
btw;而不是''@birthdate'';只有'throw'的'try' /'catch'沒有增加任何內容:你可能會刪除所有這些。 –
但是你絕對**應該擁有的是圍繞'objconn'使用'' - 此時你並沒有正確地關閉連接,並且你會很快填滿連接池(應該*也是*使用'圍繞'objcommand',但那一個只是「壞」,而不是「致命」) –