更新SQL不起作用

时间:2015-05-06 12:47:09

标签: sql datetime sql-update vb.net-2010

这是我的SQL语句:

query = "Update(tbl_shifts) SET StartTime=" & starttime & ", Endtime =" & endtime & ", TotalHours =" & totalhours & ", TotalPay=" & pay & ", Completed =" & True & "WHERE ShiftDate=" & DateTime.Today And "EmployeeName =" & EmployeeLogin.usersname

点击按钮后,应该添加变量(starttime,endtime,totalhours,pay)并勾选yes / no' Completed'在tbl_shifts行中的字段,其中“EmployeeName'”列中的条目匹配全局变量' EmployeeLogin.usersname'并且列ShiftDate中的条目(当前存储为DD/MM/YYYY HH:MM:SS)与DateTime.Today匹配(仅DD/MM/YYYY(我认为))。我该怎么做才能让我的SQL按预期工作?

1 个答案:

答案 0 :(得分:0)

您的查询中有一些拼写错误

此:

query = "Update(tbl_shifts) SET StartTime=" & starttime & ", Endtime =" & endtime & ", TotalHours =" & totalhours & ", TotalPay=" & pay & ", Completed =" & True & "WHERE ShiftDate=" & DateTime.Today And "EmployeeName =" & EmployeeLogin.usersname

应该是:

query = "Update tbl_shifts SET StartTime=" & starttime & ", Endtime =" & endtime & ", TotalHours =" & totalhours & ", TotalPay=" & pay & ", Completed =" & True &  " WHERE ShiftDate=" & DateTime.Today & " And EmployeeName =" & EmployeeLogin.usersname

所以

  • 更新tbl_shifts
  • WHERE之前的空格键
  • 在"之前移动双引号和EmployeeName