简体   繁体   English

使用vb.net 2010锁定后端访问数据库中的表

[英]Locking tables in a backend access database using vb.net 2010

My problem is that I need to use a access database as a backend for my visual basic.net program. 我的问题是我需要使用访问数据库作为我的visual basic.net程序的后端。

The database will be accessed by a maximum of 10 users but I want to lock tables when a user is updating a record. 最多10个用户将访问该数据库,但我想在用户更新记录时锁定表。

I am unable to use the SQL server at the company due to it storing sensitive information. 由于存储敏感信息,我无法在公司使用SQL服务器。

I have some basic knowledge of ado.net 我有一些ado.net的基本知识

I have read many articles but I can't find any articles that say how to lock a access .mdb file using Visual basic.net 我已阅读了很多文章,但我找不到任何文章说明如何使用Visual Basic.net锁定访问.mdb文件

I am aware that a SQL server is a better option but this is not possible option for me at the moment 我知道SQL服务器是一个更好的选择,但目前这不是我的选择

I suspect that your best bet is to add a "Locks" table which contains a record for each table in your database and a flag that indicates if the table is locked or not. 我怀疑你最好的办法是添加一个“Locks”表,其中包含数据库中每个表的记录,以及一个表示表是否被锁定的标志。

The calling methods would be responsible for checking this table prior to executing their code. 调用方法将负责在执行代码之前检查该表。

Because you will be working with individual records, the Access record locking mechanism should prevent simultaneous updates of a single record in this table, but if you get a lock, you should probably double-check it after obtaining it to ensure that it is valid. 因为您将使用单个记录,所以Access记录锁定机制应该阻止同时更新此表中的单个记录,但是如果您获得锁定,则应该在获取锁定后仔细检查它以确保它是有效的。

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

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