2017-04-11 126 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 
相關問題