使用vb 6.0的查询表达式中的语法错误

时间:2016-05-10 12:25:09

标签: vb6

sql = "update Attendance set Attended=Attended+1 where Student ID like 15001"
db.Execute (sql)

显示:

  

"查询表达式中的语法错误(缺少运算符)'学生ID如   15001'

3 个答案:

答案 0 :(得分:0)

如果真的在学生和ID tehn之间有空格,那么您的查询必须是:

sql = "update Attendance set Attended=Attended+1 where [Student ID] like 15001"
db.Execute (sql)

答案 1 :(得分:0)

sql应该始终用_写。例如,学生ID应始终为Student_ID,以便它能够读取筛选其搜索所需的列。为了将来的目的,始终使用_创建列名。

sql = "update Attendance set Attended=Attended+1 where Student_ID like 15001"
db.Execute (sql)

sql = "update Attendance set Attended=Attended+1 where [Student ID] like 15001"
db.Execute (sql)

答案 2 :(得分:0)

尝试一些看起来更清洁的东西......

sql = "Update tblAttendance SET "
sql = sql & " Attended = Attended + 1 "
sql = sql & " Where Student_ID = 15001 "
db.execute SQL <-- no paranthesis