【问题标题】:sql statement is not functioning properlysql 语句无法正常运行
【发布时间】:2017-09-06 05:17:35
【问题描述】:

我写了一个sql 声明,允许我从Datagrid 中删除学生。我想改变它,所以它将除了两个字段之外的所有值都更改为 0,当我尝试这样做时,它给了我这个错误:

UPDATE 语句中的语法错误。

这是原始代码: sql = "update Table1 set [Active] = 'No' where ID =" & SID

这是我修改为: sql = "update Table1 set [Mark 1 ENG], [Mark 2 ENG] {removed the others so it does not get clustered} = '0' where ID =" & SID

If YNResponse = vbYes Then
    sql = "update Table1 set [Mark 1 ENG], [Mark 2 ENG] = '0' where ID =" & SID  'find the student and delete them
If CurrentCon.State = adStateOpen Then              
    CurrentCon.Close
End If
    CurrentCon.Open
    CurrentCon.Execute sql
    Adodc1.ConnectionString = Conn.connstr
    Adodc1.CommandType = adCmdText
    Set StudentTable.DataSource = Adodc1
    CurrentCon.Close
    CurrentCon.Open
    Adodc1.Refresh
    frmStudents.Adodc1.Recordset.Sort = "[ID] "

【问题讨论】:

    标签: sql datagrid vb6 ado recordset


    【解决方案1】:

    这就是问题

    sql = "update Table1 set [Mark 1 ENG], [Mark 2 ENG] = '0' where ID =" & SID  'find the student and delete the
    

    应该在哪里

    update table1 set [Mark 1 ENG] = 0, [Mark 2 ENG] = 0
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-20
      • 1970-01-01
      • 2020-01-30
      相关资源
      最近更新 更多