这是我的代码:
Dim job As String = TextBoxJobNum.Text
Dim idws As Integer
sqlQuery =“UDATE Equipment SET JobHistory = JobHistory +'”&工作与“'WHERE ID ='”& idws& “'”
Dim sqlCmd1 As New SqlCommand(sqlQuery, sqlConn)
If sqlConn.State = ConnectionState.Closed Then sqlConn.Open()
For Each row As DataGridViewRow In DataGridViewEquip.Rows
idws = CInt(row.Cells(0).Value)
sqlCmd1.ExecuteNonQuery()
Next
If sqlConn.State = ConnectionState.Open Then sqlConn.Close()
我收到错误“'='附近的语法错误”我到处搜索但似乎无法找到 正确此行的语法。任何帮助将不胜感激。
答案 0 :(得分:1)
在我看来,你只是在“更新”一词中错过了一个“P”
sqlQuery = "UPDATE Equipment SET JobHistory = JobHistory+'" & job & "' WHERE ID = '" & idws & "'"
另外,我建议不要使用字符串连接设置参数,而是使用parameters on a SqlCommand object。这样做的原因是减少了潜在的问题,例如额外的转义(例如“作业”变量包含“'”)或SQL注入。