跟踪或通知数据库更改 - 主要是插入和更新

发布于 2024-07-09 14:23:15 字数 164 浏览 9 评论 0原文

每当在数据库中插入或更新记录时,如何跟踪或收到通知? 每当数据库发生此类更改时,我想近乎实时地将更改通知外部应用程序。 是否有独立于 DBMS 和应用程序编程语言的方法来执行此操作? 如果不能,那么尤其是 MS Access 和 MS SQL Server 是否可以实现? 当然,我希望避免连续轮询数据库。

How do I track or get notified whenever a record is inserted or updated in a DB? I would like to notify an external application of the changes in near real time whenever such changes in DB occur. Are there DBMS independent and application programming language independent ways of doing this? If not, then is it possible with MS Access and MS SQL Server in particular? I'm looking to avoid continuous polling of DB of course.

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

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

发布评论

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

评论(4

临走之时 2024-07-16 14:23:17

使用 MS-Access,我可以使用主表中的字段来跟踪记录更改或记录添加,这些字段存储创建或更新记录时的用户名和日期。

您需要使用Windows API来记录用户名,通常在打开总机表单时运行。

我正在努力寻找一种方法来跟踪特定的变化。 我的数据库用于项目管理。 我想跟踪具体更改的内容,而不仅仅是我现在更改的人员和时间。

我认为这符合原问题的要求。 我可以稍后添加读取用户名的 Windows API。

私有子表单_BeforeInsert(取消为整数)
Me!UserCreated = UCase(CurrentUser())
我!创建日期 = Now()
End Sub

私有子表单_BeforeUpdate(取消为整数)
Me!DateModified = Now()
Me!UserModified = UCase(CurrentUser())
尾声

——迈克

With MS-Access, I keep track of record changes or record additions with fields in the main table that store the user name and date when the record is created or updated.

You need to use a windows API to record the user name, usually run when switchboard form is opened.

I am digging to find a away to track specific changes. My data base is used for project management. I would like to keep track of what specifically was changed, not just who and when that I have now.

I think this meets the requirements of the original question. I can later add the windows API that reads the name of the user.

Private Sub Form_BeforeInsert(Cancel As Integer)
Me!UserCreated = UCase(CurrentUser())
Me!DateCreated = Now()
End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me!DateModified = Now()
Me!UserModified = UCase(CurrentUser())
End Sub

-- Mike

病毒体 2024-07-16 14:23:17

要使用 SQL Server 执行此操作,您可以使用通知服务 - 编写一个 dll,该 dll 订阅来自数据库的数据更新通知,您可以通过某种方式处理这些数据更新。

然而,MS 表示他们正在 从 SQL 中删除此内容服务器 2008

Oracle 有类似的东西(尽管他们倾向于保留自己的技术),但我还没有看到任何与数据库无关的东西。

To do this with SQL Server, you use the Notification Service - write a dll that subscribes to notifications from the DB for data updates which you can process in some way.

However, MS has said that they are removing this from SQL Server 2008.

Oracle has something similar (though they tend to leave their technology in place), but I've not seen anything that is database-neutral.

贪了杯 2024-07-16 14:23:16

使用 SQL Server,可以在 SQL Server 本身中加载 DLL,并使用扩展存储过程从该 DLL 调用方法。 然后,DLL 可以通知其他应用程序 - 通常通过 TCP 套接字。

With SQL Server it is possible to load a DLL within SQL Server itself and call methods from this with extended stored procedures. The DLL could then notify other applications - usually via a TCP socket.

止于盛夏 2024-07-16 14:23:16

我认为最新版本的 Microsoft SQL Server 允许您根据服务器条件和事件在 .NET 代码中引发事件。 我还没有尝试过,也没有听说过任何“独立于 DBMS”的方法(无需每 X 毫秒轮询一次数据库)。

I think the latest version of Microsoft SQL Server allows you to raise events in your .NET code based on server conditions and events. I haven't tried it, and I haven't heard of any 'DBMS independent' way of doing this (without polling DB every X milliseconds).

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