检测 Microsoft Access 数据库表的上次更改时间

发布于 2024-07-22 16:39:40 字数 140 浏览 1 评论 0原文

有谁知道一种方法来检测 Microsoft Access 表上次更改(插入或更新)的时间? 我们通过 ADO COM 使用 OLEDB 以编程方式与访问数据库进行通信,并正在寻找一种检测特定表更改的方法。 我们不需要知道这些改变是什么,只需要知道发生了什么改变。

Does anyone know of a way to detect when the last time a Microsoft Access table has been changed (inserted into or updated)? We used OLEDB via ADO COM to communicate with an access database programmatically and were looking for a way of detecting changes to specific tables. We don't need to know what those changes are, just that changes were made.

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

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

发布评论

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

评论(4

这样的小城市 2024-07-29 16:39:40

检测表中的数据是否已更改的唯一方法是对表执行查询。

您必须向表中添加一个DATETIME 类型的列,例如名为LastUpdatedDate 的列,该列指示每行的上次更新日期/时间。 将其设为 NOT NULL,以便您必须为每个 INSERTUPDATE 向该列写入更新的 DATETIME 值>。 另外,将该列设置为当前日期戳的默认值 DATE() 或当前日期/时间戳的默认值 NOW()。 然后添加验证规则或 CHECK 约束,例如 CHECK (LastUpdatedDate = NOW()) 以确保该列在每次 UPDATE 和 <代码>插入。

最后,运行 MAX(LastUpdatedDate) 查询,您将获得所需的结果。

The only way to detect if data in the table has changed is to perform a query against the table.

You must add a column of type DATETIME to the table e.g. named LastUpdatedDate that indicates the last updated date/time of each row. Make it NOT NULL so that you will have to write an updated DATETIME value to that column for each INSERT or UPDATE. Also, set the column to have a default of DATE() for the current date stamp or NOW() for the current date/time stamp. Then add a Validation Rule or CHECK constraint e.g. CHECK (LastUpdatedDate = NOW()) to ensure the column is actually updated on each UPDATE and INSERT.

Finally, run a MAX(LastUpdatedDate) query and you will get what you need.

暮年慕年 2024-07-29 16:39:40

每次访问表时,没有办法不“手动”写入列。

There isn't a way without "manually" writing to a column each time you access the table.

牵你手 2024-07-29 16:39:40

正如其他人所指出的,如果不自己编码,就无法跟踪更改。

有一个简单的例子
ACC2000:如何在表单中创建记录更改的审计跟踪
http://support.microsoft.com/default.aspx? scid=kb;en-us;Q197592

审核跟踪 - 在记录级别记录更改:
http://allenbrowne.com/AppAudit.html
本文讨论了表单和子表单的编辑、插入和删除。

模块:维护变更历史记录
http://www.mvps.org/access/modules/mdl0021.htm
历史表例程旨在写入历史记录,跟踪对一个或多个表中的字段所做的更改。

As others have indicated there is no way to track changes without coding it yourself.

There's a simple example at
ACC2000: How to Create an Audit Trail of Record Changes in a Form
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q197592

Audit Trail - Log changes at the record level at:
http://allenbrowne.com/AppAudit.html
The article addresses edits, inserts, and deletes for a form and subform.

Modules: Maintain a history of changes
http://www.mvps.org/access/modules/mdl0021.htm
The History Table routine is designed to write history records that track the changes made to fields in one or more tables.

情域 2024-07-29 16:39:40

您将需要在表中实现时间戳列,并在数据更改期间更新该值。

You will need to implement a timestamp column in your table, and update the value during your data changes.

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