我的sql语句有什么问题

时间:2014-03-28 15:54:10

标签: sql excel vba

我在VBA做一个项目。我已经成功连接并检索了我的表格。现在我想从Excel更新几个列。当我运行此代码时,它不会抛出任何错误,但我的表中的值永远不会改变。

sqlstr = "UPDATE " & table4 & " SET price = '" & Cells(i, 8) & ", & " 
& Cells(i, 9) & "' " & " WHERE key_id = '" & Cells(i, 1) & ", & " & Cells(i, 2) & "' "

当我使用一个值运行较短版本时,它会更新它。

sqlstr = "UPDATE " & table4 & " SET price = '" & Cells(i, 8) & "' " & " 
WHERE key_id = '" & Cells(i, 1) & "' "

我哪里错了?

1 个答案:

答案 0 :(得分:0)

你在语法

中遗漏了'引号
sqlstr = "UPDATE " & table4 & " SET price = '" & Cells(i, 8) & "' " & " 
& Cells(i, 9) & "' " & " WHERE key_id = '" & Cells(i, 1) & ", & " & Cells(i, 2) & "' "