简体   繁体   English

带有 SQL 服务器后端的 MS Access 前端 - integer 密钥超出范围

[英]MS Access frontend with SQL Server backend - integer key is out of range

I've a MS Access solution accessing to linked tables to SQL Server.我有一个 MS Access 解决方案,可以访问 SQL 服务器的链接表。 Today it happens that one key filed in a table reached the limit of int.今天碰巧一个表中的key filed达到了int的限制。

So my first idea was to change it from int -> bigint but it seems to be not possible as ALTER queries return a couple of errors for.所以我的第一个想法是将它从 int -> bigint 更改,但它似乎是不可能的,因为 ALTER 查询返回了几个错误。

The second idea was to clone the key field, delete original and make the clone to the new key field.第二个想法是克隆关键字段,删除原始字段并克隆到新的关键字段。 This worked without problems but now the linked table only show #deleted values for all fields within the table.这没有问题,但现在链接表只显示表中所有字段的#deleted 值。 It seems that MS Access uses the keys for some relations when it access to the backend.似乎MS Access在访问后端时使用了某些关系的密钥。

Maybe somebody know a solution to extend /reset the key without loosing the relation for MS Access?也许有人知道在不失去 MS Access 关系的情况下扩展/重置密钥的解决方案?

Thank you谢谢

MsAccess has a "long integer" number option in the table design, which has the same size of INT from SQL Server. MsAccess在表设计中有一个“长整型”数字选项,它与来自SQL Server的INT大小相同。 See below:见下文:

在此处输入图像描述

https://www.microsoft.com/en-us/microsoft-365/blog/2017/03/06/new-in-access-2016-large-number-bigint-support/ https://www.microsoft.com/en-us/microsoft-365/blog/2017/03/06/new-in-access-2016-large-number-bigint-support/

I found this: "Unfortunately, Access is unable to use BigInt as a primary key. You will most likely need to change this to a long integer. The article below is for an older version of Access, but the info still applies:" ( https://answers.microsoft.com/en-us/msoffice/forum/all/linked-table-showing-deleted-in-all-rows-and/d0451a78-08c1-4667-8677-6c61edcebcf1 )我发现了这个:“不幸的是,Access 无法将 BigInt 用作主键。您很可能需要将其更改为长 integer。下面的文章适用于旧版本的 Access,但信息仍然适用:”( https://answers.microsoft.com/en-us/msoffice/forum/all/linked-table-showing-deleted-in-all-rows-and/d0451a78-08c1-4667-8677-6c61edcebcf1 )

So it seems not to be possible to use bigint as key.所以似乎不可能使用 bigint 作为键。

I Googled this topic, and this is what I found...我用谷歌搜索了这个主题,这就是我发现的……

Access CAN handle the BigInt datatype in SQL Server. Access 可以处理 SQL 服务器中的 BigInt 数据类型。 Only, its handling of this is somewhat faulty.只是,它对此的处理有些失误。

As far as Access is concerned, BigInt is a STRING.就 Access 而言,BigInt 是一个 STRING。 You have to quote it as a string, within Access.您必须在 Access 中将其作为字符串引用。 Fortunately this isn't a problem on the SQL Server end, as SQL Server is happy with quoted numbers.幸运的是,这在 SQL 服务器端不是问题,因为 SQL 服务器对引用的数字很满意。 In-between the two (Access and SQL Server), based on my experience, it appears there is a textual transmission of SQL commands from Access to SQL Server, with some modest dialect translation going on automatically in the background (if anyone knows better, please comment.) BigInt data coming from SQL Server to Access are automatically understood as strings.在这两者(Access 和 SQL Server)之间,根据我的经验,似乎有 SQL 命令的文本传输从 Access 到 SQL Server,在后台自动进行一些适度的方言翻译(如果有人知道的话,请发表评论。)从 SQL 服务器到访问的 BigInt 数据会自动理解为字符串。

https://social.msdn.microsoft.com/Forums/office/en-US/fb6f99ec-2ed7-487b-ba39-0777a0b44d5f/the-bigint-problem?forum=accessdev https://social.msdn.microsoft.com/Forums/office/en-US/fb6f99ec-2ed7-487b-ba39-0777a0b44d5f/the-bigint-problem?forum=accessdev

MS Access is a 30 year old technology. MS Access 是一项已有 30 年历史的技术。 Do you really want to be using that in 2022 and in the future?你真的想在 2022 年和未来使用它吗?

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

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