sql语句无法正常运行

时间:2017-04-11 01:41:59

标签: sql datagrid vb6 ado recordset

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

  

UPDATE语句中的Synatx错误。

这是原始代码: 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] "

1 个答案:

答案 0 :(得分:1)

这就是问题

return

应该在哪里

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