Tutorial :Delphi 2009 ADO database access in cmShareDenyWrite mode


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


try on the AfterOpen Event on the TADOQuery looping though TDataSet->Fields settings the read only value to true.

this might work ive had a simular problem but it was in c++builder2010 so it might not work.


It seems to me you want adModeShareExclusive, which should open the MDB in exclusive mode. That is, you can write to it, but everyone else is prohibited all access, read or write. This is something that is definitely supported by Jet/ACE, so the issue was really only whether or not the Jet OLEDB wrapper supported it.

Of course, I'm an Access programmer, not a Delphi programmer, so I could be wrong, but I'm looking at the definitions from the ADO type library in Access. The value of adModeShareExclusive is 12, in case it's not available as a constant in your programming environment.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »