0

I have a Delphi 2009 application that is attempting to open an ADO connection (dbGo) to a Microsoft Access .MDB file in cmShareDenyWrite mode, using the Jet 4.0 OLE DB provider. The goal is to open the .MDB file in read/write mode, but to prevent other applications from opening the file in write mode: Other applications accessing the file in read mode concurrently is OK -- in fact, that's the whole point.

I am using a combination of TADOConnection, TADOQuery (and/or TADOTable) and TDataSource, connecting to data-aware controls. My understanding from reading the documentation (and reading, and reading) is that setting the access permissions in the Connection string to "Share Deny Write" would do the trick.

I have no problem opening the database: The returned mode in the ADOConnection upon successful connecting is cmShareDenyWrite, as expected. I have no problem navigating the dataset using my data-aware controls. However, when I attempt to alter a record and post the results, I am unable to: The database seems to be in read-only mode.

Essentially, it seems that choosing "Share Deny Write" for ADO access to an MDB table denies ME the ability to write to the file. Either I'm missing something, or this is an unsupported scenario for the OLE DB provider for JET.

Does anyone have any idea where I'm going wrong, or how I can accomplish my original goal?

Thanks in advance,

John Bennett

4

2 回答 2

1

尝试在 TADOQuery 循环上的 AfterOpen 事件,但 TDataSet->Fields 将只读值设置为 true。

这可能有效,我有一个类似的问题,但它在 c++builder2010 中,所以它可能不起作用。

于 2010-01-09T01:10:46.110 回答
0

在我看来,您想要 adModeShareExclusive,它应该以独占模式打开 MDB。也就是说,您可以对其进行写入,但禁止其他所有人访问、读取或写入。这是 Jet/ACE 绝对支持的东西,所以问题实际上只是 Jet OLEDB 包装器是否支持它。

当然,我是 Access 程序员,而不是 Delphi 程序员,所以我可能是错的,但我正在查看 Access 中 ADO 类型库的定义。adModeShareExclusive 的值为 12,以防它在您的编程环境中不能作为常量使用。

于 2010-01-09T02:56:39.470 回答