访问前端,SQL Server 后端跳过自动编号 ID

发布于 2024-08-15 18:42:36 字数 325 浏览 3 评论 0原文

问题标题是问题的关键。我有一个 Access 2007(2003 格式)前端和一个 SQL Server 2008 Express 后端。输入表单有一个链接到另一个表的子表单。在主窗体中添加记录时,表的 PK 字段(设置为自动增量)会跳过大约四个 ID(我说大约是因为有时是 3 个,有时是 5 个,有时是 4 个)。

为了说明这一点,如果最后一个 ID 是 1234,则新记录的 ID 可能是 1238。

我已经单步执行了代码,但没有找到任何表明多次保存或删除的内容。无论是否向子表单添加任何记录,此问题都会出现。

我意识到这可能是任何事情,但我希望有人可能对调查途径有一些见解或建议。

Question title is the crux of the problem. I have an Access 2007 (2003 format) front-end with a SQL Server 2008 Express back-end. The input form has a subform linked to another table. When adding a record in the main form, the PK field of the table (set to auto increment) is skipping about four IDs (I say about because sometimes it's three, sometimes five, sometimes 4).

To illustrate, if the last ID is 1234, the ID of the new record might be 1238.

I've stepped through the code, but haven't found anything that would indicate multiple saves or deletes. This problem manifests regardless of whether any records are added to the subform.

I realize this could be anything, but I'm hoping someone might have some insight or suggestions of avenues to investigate.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

遗忘曾经 2024-08-22 18:42:36

可能是表中的某些 INSERT 是在事务内完成的,然后事务会回滚 - 这会耗尽 ID,留下间隙。

It could be that some INSERTs in the table are being done within a transaction and the transaction is then rolled back - this would use up IDs, leaving gaps.

倾城月光淡如水﹏ 2024-08-22 18:42:36

检查数据库上的身份规范以查看身份增量是什么。它可能会以大于 1 的间隔递增,但这并不能解释你的奇数编号。这是一个很好的起点。

此外,您可能会让人们开始一条记录,然后将其删除,同时回滚事务并增加增量。

Check the Identity specification on the database to see what the Identity Increment is. It may be incrementing at an interval greater than 1, though that wouldn't explain your odd numbering. It's a good starting point.

Also, you could be having people start a record and then deleting it ala the transactions being rolled back and the incrementer being increased.

摇划花蜜的午后 2024-08-22 18:42:36

启动 sql profiler 并观察 RPC:Completed 和 SqlStmt:Completed 事件以查看到底执行了什么。

SQL Server 不会无缘无故地跳过数字。看起来它正在插入某些内容并将其回滚或插入行失败。

fire up sql profiler and observer the RPC:Completed and SqlStmt:Completed events to see what exactly is getting executed.

SQL Server doesn't just skip numbers for no reason. it looks like it's inserting something and rolling it back or inserting rows fail.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文