首页 > 解决方案 > “Operation must use an updateable query” error in MS Access

问题描述

This question has been asked many times, my case seems to be the simplest, still I did not find the answer to my question...

The environment is Windows, Access 2013. Table tbl_rap is linked, resides on MS SQL Server 2007

Table tbl_rap is constructed as follows:

id - int (Identity)
field_1 nchar(10)
field_2 nchar(1)

The following code works

sql_cmd = "INSERT INTO tbl_rap (field_1,field_2) VALUES ('010308HB3','R')"
DoCmd.RunSQL sql_cmd

But this code

sql_cmd = "UPDATE tbl_rap SET field_2 = 'X' WHERE field_1 = '010308HB3'"
DoCmd.RunSQL sql_cmd

fails with run-time error 3037 "Operation must use an updateable query"

Any help would be appreciated.

标签: sqlsql-servervbams-access

解决方案


当您使用 nchar(10) 时,您必须传递一个 10 个字符的字符串,例如:

sql_cmd = "UPDATE tbl_rap SET field_2 = 'X' WHERE field_1 = '010308HB3 '"

推荐阅读