简体   繁体   中英

C# Access Database Update Syntax Error

Is there something wrong with this query?

"UPDATE tb_EmployeeMasterList SET [EmployeeID] = " + txt_EmpId.Text +", [LastName] = '" + txt_LN.Text + "', [FirstName] = '" + txt_FN.Text + "', [MiddleName] = '" + txt_MN.Text + "', [PositionOrSkill] = '" + txt_PorS.Text + "', [BasicSalary] = " + txt_Basic.Text + ", [Allowance] = " + txt_Allow.Text + ", [Total] = " + total + ", [EPAproposedBonus] = " + txt_Bonus.Text + ", [Remarks] = '" + txt_Remarks.Text + "' WHERE ([LastName] = '" + LN + "' AND [FirstName] = '" + FN + "');"

I keep on Getting syntax error on that query alone.

There seems to be a pair of single quotes missing:

"UPDATE tb_EmployeeMasterList SET [EmployeeID] = " + txt_EmpId.Text +",

Should be:

"UPDATE tb_EmployeeMasterList SET [EmployeeID] = '" + txt_EmpId.Text +"', 

尝试在不带括号的情况下触发WHERE语句

"UPDATE tb_EmployeeMasterList SET [EmployeeID] = " + txt_EmpId.Text +", [LastName] = '" + txt_LN.Text + "', [FirstName] = '" + txt_FN.Text + "', [MiddleName] = '" + txt_MN.Text + "', [PositionOrSkill] = '" + txt_PorS.Text + "', [BasicSalary] = " + txt_Basic.Text + ", [Allowance] = " + txt_Allow.Text + ", [Total] = " + total + ", [EPAproposedBonus] = " + txt_Bonus.Text + ", [Remarks] = '" + txt_Remarks.Text + "' WHERE [LastName] = '" + LN + "' AND [FirstName] = '" + FN + "';"

如果为total ,则LNFN值来自变量而不是文本框,则语法正常,但文本框然后在其后添加.Text,否则会出现语法错误。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM