阻止提交对 Microsoft Access 数据库的更改
有没有办法编写一个在将更改提交到 Access DB 之前运行的挂钩?如果特定进程当前正在查询数据库,我正在寻找一种阻止更改的方法。
Is there a way to write a hook that will run before changes are committed to an Access DB? I'm looking for a way to block changes if a specific process is currently querying the DB.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你没有给我们提供太多可以使用的信息。您可以调整类似 创建并使用灵活的自动编号字段,因此特定流程首先以独占方式打开一个表?然后,任何其他可能更改数据的操作都必须等待,直到它们可以锁定同一个表。
具体流程是什么?您是否有方法确定何时/是否从数据库读取数据?
如果特定进程位于数据库外部,例如使用 ADO 获取数据的 Web 服务器 ASP 代码,您可以查看 ADO 连接模式和 IsolationLevel 属性是否有帮助。
更新:我使用表单来试验 ADO 连接的 adModeShareDenyWrite Mode 属性。当表单打开时,其他用户可以打开数据库,但不能进行任何更改。但是,如果在表单尝试打开连接时另一个用户已经打开了数据库,则会触发错误。
也许您的部署脚本可以尝试打开 adModeShareDenyWrite 连接,并在出现错误时退出。
You didn't give us much information to work with. Can you adapt something like Create and Use Flexible AutoNumber Fields so specific process first opens a table exclusively? Then any other operations which might change data would have to wait until they can lock that same table.
What is specific process? Do you have a method to determine when/if it is reading data from your database?
If specific process is external to the database, like web server ASP code which uses ADO to fetch data, you could see whether the ADO connection Mode and IsolationLevel properties can help.
Update: I used a form to experiment with the adModeShareDenyWrite Mode property for an ADO connection. While the form is open, other users can open the database, but not make any changes. However, if another user already has the db open when the form attempts to open the connection, it triggers an error.
Perhaps your deployment script could attempt to open a adModeShareDenyWrite connection, and bail out on error.