Open MDB file on write protected disk

How can I work with an existing MDB file by using DAO functions on the write protected disk? I need just to read data from this file. The problem is related to the lock file which is always created on opening.
bikulovAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mark2150Commented:
Open for read only. Also make sure the MDB was flagged R/O when it was saved to disk.

This has been answered before and does work.

M
0
bikulovAuthor Commented:
I open MDB file as read only. And I get LDB file 64 bytes long created in the same folder. MDB file was created in Microsoft Access. Marking MDB file as read only does not bring any difference. I can't get rid of the LDB file.
0
mark2150Commented:
Search the PAQ on this. There is a *simple* solution. The above steps are part of the solve.  Lemme check my Q history ...

M
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

mark2150Commented:
FOUND IT!

Here is a thread that gives the answer you're after:

You do NOT need an LDB if you're only using the database for lookup. Open it R/O and with dbSnapShot. Also mark the database file R/O. This will alert the program that you don't want a lock file to be created. This is the same solution as opening a database that's on a CD-ROM drive.

From the help:

Set database = workspace.OpenDatabase (dbname, options, read-only, connect)

....

Settings

For Microsoft Jet workspaces, you can use the following values for the options argument.

Setting Description
True Opens the database in exclusive mode.
False (Default) Opens the database in shared mode.

This does work, I don't have the syntax handy, but you can open a CD-ROM database programmatically.
=================================================================
I have done what you suggested, but it seems the only way to eliminate the need for a locking file is to set the opendatabase method "option" to true - exclusive use. Even if the read-only flag is set to true. I have not been able to fully test this with multiple machines, but I have a multi-user situation. Several users may be attempting to read the database at the same time. They can't get "the database is already opened exlusively by another user" message. So I need to eliminate the .ldb file and still maintain multiple users hitting the database for reads.
=================================================================
If the OpenDatabase options and read-only flag are set to true, and all of the recordsets are snapshots (dbOpenSnapshot), the program will not create an .ldb file but will allow multiple reads.

M
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bikulovAuthor Commented:
Thanks. In fact it was even more easy in my case. I am using CDaoDatabase class. The following 'Open' options solved the problem:
Open("database.mdb", TRUE, TRUE, _T(""));
Database file does not even require read only flag. The key point was in "exclusive mode".
0
mark2150Commented:
Yep. But the R/O flag is useful in that it helps the JET engine decide that it shouldn't *TRY*. Be sure to set it when you make your CD's.

M
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Hardware

From novice to tech pro — start learning today.