简体   繁体   English

无法删除和更新访问链接表上的记录

[英]cannot delete and update records on access linked table

I have access database called road.mdb. 我有访问数据库名为road.mdb。 Inside road.mdb, I have a linked SQL table and 在road.mdb里面,我有一个链接的SQL表和
the table name is student. 表名是学生。

I can insert records using query design in MSAccess 我可以在MSAccess中使用查询设计插入记录

But I cannot update nor Delete 但我不能更新也不能删除

when run delete query below, the error is: could not delete from specified table 当运行删除查询时,错误是:无法从指定的表中删除

delete from student where studentid=303;

and when I run update query below, the error is: Operation must use an updateable query 当我在下面运行更新查询时,错误是:操作必须使用可更新的查询

update student set Name='BOB' where studentid= 303;

I have full access to the sql database and I can run the query OK using sql management studio. 我可以完全访问sql数据库,我可以使用sql management studio运行查询。 Is it impossible to delete and update using query design inside MSaccess?? 是不是可以在MSaccess中使用查询设计删除和更新? The weird thing is I can insert new records using query design inside MSaccess 奇怪的是我可以使用MSaccess中的查询设计插入新记录

thank you 谢谢

I SOLVED this by adding primary key to the SQL table and re linked the table to ACCESS 我通过向SQL表添加主键并将表重新链接到ACCESS来解决这个问题

Thanks everyone... 感谢大家...

In the case that you can't manipulated the table on SqlServer, you can get around the problem by telling Access which/s column/s are meant to be the primary key. 如果您无法在SqlServer上操作表,则可以通过告知Access哪个/哪些列是主键来解决问题。 This is done on the last step of creating a Linked table, the window title is "Select Unique Record Identifier". 这是在创建链接表的最后一步完成的,窗口标题是“选择唯一记录标识符”。

You will find that the following steps will most likely solve your problem: 您会发现以下步骤很可能会解决您的问题:

  1. In SQL Server: set a primary key on the table you are working with and make sure the primary key is of type int, not bigint as Access will not properly deal with bigint data type. 在SQL Server中:在您正在使用的表上设置主键,并确保主键的类型为int,而不是bigint,因为Access将无法正确处理bigint数据类型。
  2. In SQL Server: refresh the table. 在SQL Server中:刷新表。
  3. In MS Access: re-link the table. 在MS Access中:重新链接表。

(You can easily check if 'things are OK' afterwards by adding a record to the SQL Server table and accessing it through the MS Access linked table. When all is OK you should not see #Deleted when viewing the data from MS Access side.) Hope it helps ;-) (之后您可以通过向SQL Server表添加记录并通过MS Access链接表访问它来轻松检查“事情是否正常”。当一切正常时,从MS Access端查看数据时,您不应该看到#Deleted。 ) 希望能帮助到你 ;-)

In my case, the linked table only had keys. 就我而言,链接表只有键。 I had to modify one of the keys to be a primary key and then I could truncate truncate the table via a DELETE table.* FROM table via access. 我不得不修改其中一个键作为主键,然后我可以截断通过DELETE表截断表。* FROM表通过访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM