• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 414
  • Last Modified:

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.
0
bikulov
Asked:
bikulov
  • 4
  • 2
1 Solution
 
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
Will You Be GDPR Compliant by 5/28/2018?

GDPR? That's a regulation for the European Union. But, if you collect data from customers or employees within the EU, then you need to know about GDPR and make sure your organization is compliant by May 2018. Check out our preparation checklist to make sure you're on track today!

 
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
 
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

Featured Post

Will You Be GDPR Compliant by 5/28/2018?

GDPR? That's a regulation for the European Union. But, if you collect data from customers or employees within the EU, then you need to know about GDPR and make sure your organization is compliant by May 2018. Check out our preparation checklist to make sure you're on track today!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now