下面是我的更新查询,它工作正常,但是当我int DrId
(最后)添加参数字段以检查 where 条件时,在此之后它向我显示以下错误
No value given for one or more required parameters.
错误在哪里,因为DrId
是我的主键,我不会更新它
public bool UpdateDrMaster(string title, string FirstName, string Mname, string lastName, string regNo, string speciality, string contactNo1, string contactNo2, string city, string addrss, string pincode, string emailId, string fee_unit, string fee, string DrType, bool displayType,int DrId)
{
bool flag = false;
try
{
string sql = "UPDATE Doctor_Master SET [Title]=@Title,[FirstName]=@FirstName,[MiddleName]=@MiddleName,[LastName]=@LastName,[RegistrationNo]=@RegistrationNo,[Speciality]=@Speciality,[ContactNo_1]=@ContactNo_1,[ContactNo_2]=@ContactNo_2,[City]=@City,[Address]=@Address,[Pincode]=@Pincode,[Email_ID]=@Email_ID,[Fee_Unit]=@Fee_Unit,[Fee]=@Fee,[Type_of_Dr]=@Type_of_Dr,[Display]=@Display,[Hide_Date]=@Hide_Date WHERE Doctor_ID=" +DrId;
cmd = new OleDbCommand(sql, acccon);
cmd.Parameters.AddWithValue("@Title", title);
cmd.Parameters.AddWithValue("@FirstName", FirstName);
cmd.Parameters.AddWithValue("@MiddleName", Mname);
cmd.Parameters.AddWithValue("@LastName", lastName);
cmd.Parameters.AddWithValue("@RegistrationNo", regNo);
cmd.Parameters.AddWithValue("@Speciality", speciality);
cmd.Parameters.AddWithValue("@ContactNo_1", contactNo1);
cmd.Parameters.AddWithValue("@ContactNo_2", contactNo2);
cmd.Parameters.AddWithValue("@City", city);
cmd.Parameters.AddWithValue("@Address", addrss);
cmd.Parameters.AddWithValue("@Pincode", pincode);
cmd.Parameters.AddWithValue("@Email_ID", emailId);
cmd.Parameters.AddWithValue("@Fee_Unit", fee_unit);
cmd.Parameters.AddWithValue("@Fee", fee);
cmd.Parameters.AddWithValue("@Type_of_Dr", DrType);
cmd.Parameters.AddWithValue("@Display", displayType);
cmd.Parameters.AddWithValue("@Hide_Date", System.DateTime.Now.ToShortDateString());
cmd.ExecuteNonQuery();
flag = true;
}
catch (Exception err)
{
MessageBox.Show(err.Message.ToString());
}
return flag;
}