【问题标题】:Syntax Error in query expression with vb 6.0使用 vb 6.0 的查询表达式中的语法错误
【发布时间】:2016-05-10 12:25:09
【问题描述】:
sql = "update Attendance set Attended=Attended+1 where Student ID like 15001"
db.Execute (sql)

正在显示:

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

【问题讨论】:

  • 将字段名称 Student ID 括在适当的符号中([Student ID] 用于 Microsoft SQL)。

标签: vb6


【解决方案1】:

如果您真的在 Student 和 ID 之间有空格,您的查询必须是:

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

【讨论】:

    【解决方案2】:

    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)
    

    【讨论】:

      【解决方案3】:

      尝试一些看起来更干净的东西......

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

      【讨论】:

        猜你喜欢
        • 2014-03-22
        • 1970-01-01
        • 2015-12-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多