0

我正在尝试使用以下代码更新数据库中的数据,但它给了我语法错误,我在这里犯了什么错误

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)
        {
            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]=@,[Type_of_Dr]=@Type_of_Dr,[Display]=@Display,[Hide_Date])";

                cmd = new OleDbCommand(sql, acccon);
                 cmd.Parameters.Add("@Title", title);
                             cmd.Parameters.Add("@FirstName", FirstName);
                             cmd.Parameters.Add("@MiddleName", Mname);
                             cmd.Parameters.Add("@LastName", lastName);
                             cmd.Parameters.Add("@RegistrationNo", regNo);
                             cmd.Parameters.Add("@Speciality", speciality);
                             cmd.Parameters.Add("@ContactNo_1", contactNo1);
                             cmd.Parameters.Add("@ContactNo_2", contactNo2);
                             cmd.Parameters.Add("@City", city);
                             cmd.Parameters.Add("@Address", addrss);
                             cmd.Parameters.Add("@Pincode", pincode);
                             cmd.Parameters.Add("@Email_ID", emailId);
                             cmd.Parameters.Add("@Fee_Unit", fee_unit);
                             cmd.Parameters.Add("@Fee", fee);
                             cmd.Parameters.Add("@Type_of_Dr", DrType);
                             cmd.Parameters.Add("@Display", displayType);
                             cmd.Parameters.Add("@Hide_Date", System.DateTime.Now.ToShortDateString());                            
                cmd.ExecuteNonQuery();
                flag = true;
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message.ToString());
            }
            return flag;
        }
4

1 回答 1

1

你有无效的参数:

,[费用]=@

,[隐藏日期])

hide_date 后面的右括号也可能是错误的?

            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]=@
        ,[Type_of_Dr]=@Type_of_Dr
        ,[Display]=@Display
        ,[Hide_Date])";
于 2013-10-05T10:31:27.537 回答