Delphi 2009 ADO database access in cmShareDenyWrite mode

adodatabasedelphidelphi-2009jet

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

Best Answer

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.

Related Topic