2017-04-11 136 views
-1

我已经写了一个sql声明,它允许我从Datagrid中删除学生。我想改变这种因此它的变化,除了两个字段为0,所有的值,当我试图做到这一点它给了我这个错误:sql语句无法正常工作

Synatx error in UPDATE statement.

这是原单码: 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

这是问题

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