使用excel VBA运行更新查询 - 更新错误

时间:2017-10-18 20:14:08

标签: sql excel vba

我正在尝试使用以下代码在Excel工作表上运行更新查询:

With db
    .Provider = "Microsoft.ACE.OLEDB.12.0"
    .ConnectionString = "Data Source='" & ThisWorkbook.FullName & "'; " & "Extended Properties='Excel 12.0;HDR=YES'"
    .Mode = adModeReadWrite
    .Open
End With

sql_str = "UPDATE [unload_data$] INNER JOIN [action_combos$] ON [unload_data$].action = [action_combos$].action1 " & _
        "AND [unload_data$].pick_ticket = [action_combos$].pick_ticket SET [unload_data$].conflict = [action_combos$].invalid "

db.Execute (sql_str)

但是我收到以下错误:

Run-time error '-2147467259 (80004005)':
The Microsoft Access database engine stopped the process because you and 
another user are attempting to change the same data at the same time

现在,如果我在[unload_data$].conflict的SQL语句中硬编码一个值,它可以正常工作,但它不会使用联合表中字段的值进行更新。我在网上看了一下,但到目前为止还没有得到任何答案。

0 个答案:

没有答案