同时从多个应用程序读写单个 Ms Access 数据库

发布于 2024-12-09 11:11:59 字数 248 浏览 0 评论 0原文

我已经对此进行了测试,我可以看到可以从多个应用程序(或同一应用程序的相同多个实例)到同一个 Access 数据库打开多个 OleDbConnection,甚至可以有多个 OleDbDataReader 同时打开。

但这安全吗?我应该特别注意还是 Jet 引擎会处理所有事情?如果我在读取一个数据表的同时向同一个表写入数据,会发生什么情况?

我只是不想以后遇到陷阱或惊喜。

I've tested this and I can see is possible to have multiple opened OleDbConnections from multiple applications (or same many instances of the same application) to the same Access database, and even have many OleDbDataReader opened at the same time.

But is this safe? Should I take any special care or will the Jet engine take care of everything? What would happen if I'm reading one data table while writing to the same table at the same time?

I just don't want to stumble upon gotchas or surprises later on.

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

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

发布评论

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

评论(4

阳光的暖冬 2024-12-16 11:11:59

Access 通常不是并发数据活动的引擎。您有什么理由避免使用 MySQL 或 Oracle 或其他合适的 RDBMS?

一些原因:

- 无法保证您获得读取一致的视图。
-您很有可能在不知情的情况下更新更新的记录。
-您可能会遇到无法解析的锁
-你没有集中的交易管理器

Access is generally not the engine for concurrent data activity. Any reason why you would avoid MySQL or Oracle or other proper RDBMS?

Some reasons:

-You are not guaranteed a read consistent view.
-You get the strong possibility of updating an updated record without knowing.
-You may experience unresolvable locks
-You have no centralized transaction manager

挽你眉间 2024-12-16 11:11:59

Access 并不是为并发使用而设计的。您应该使用不同的数据库进行调查。 这是关于该主题的一篇精彩文章。

Access was not designed for concurrent usage. You should investigate using a different database. Here's an excellent article on the subject.

如何视而不见 2024-12-16 11:11:59

直接回答您的问题如果我在读取一个数据表的同时向同一张表写入数据,会发生什么情况?

取决于默认的IsolationLevel。您可以在 Protecting Your Data Integrity with ADO.Net 中的事务

但正如其他人建议的那样,请使用其他东西。 SQL Server 2008 Express 功能齐全且大部分免费。如果您仍然希望能够在不安装服务器软件的情况下使用数据库,我什至会推荐 基于 Access 的 SQL Server Compact Edition

To directly response to your question What would happen if I'm reading one data table while writing to the same table at the same time?

Depends on the default IsolationLevel. You can read about what Isolation Levels are and how to specify them at Protecting Your Data Integrity with Transactions in ADO.Net.

But as others suggested, please use something else. SQL Server 2008 Express is fully featured and mostly free. If you still want the ability to use a database without installing a server software I would even recommend SQL Server Compact Edition over Access.

沉溺在你眼里的海 2024-12-16 11:11:59

我个人的经验是,对于 5 到 10 个用户(每个用户有 1 个连接),“用户无法通过在表单中​​输入一些内容来输入更多数据”,在本地网络中使用,Access 作为后端是可以的。本文反映了我的个人经历:

http://www.tek-tips.com/ faqs.cfm?fid=4462

真正的限制以及您应该寻找“真正的”客户端/服务器数据库的点在很大程度上取决于您的环境的详细信息 - 如果您想知道,您将不得不运行你自己的基准。

关于表的并发读/写:Access 使用底层文件系统的字节范围锁定功能来处理冲突(请参见此处 http://en.wikipedia.org/wiki/File_locking 了解更多信息)。此机制适用于大多数现代文件系统(例如 NTFS),但不能很好地扩展到许多用户。

My personal experience is, for 5 to 10 users (each one with 1 connection) with "not more data a user can enter by typing some input into a form", used in a local network, Access is ok as a backend. This article reflects my personal experience:

http://www.tek-tips.com/faqs.cfm?fid=4462

The real limits and the point where you should look for a "real" Client/Server database is heavily dependent of the details of your environment - if you want to know, you will have to run your own benchmarks.

Concerning the concurrent read/writes to a table: Access uses the byte-range locking capabilities of the underlying file system to deal with collisions (see here http://en.wikipedia.org/wiki/File_locking for more information). This mechanism works on most modern file systems like NTFS, but does not scale well to many users.

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