PRB: DAO MDB on Read-Only Media Must Be Opened Exclusively (191737)
The information in this article applies to:
- Microsoft Access 97
- Microsoft Visual Studio 97
- Microsoft Visual Studio, Enterprise Edition 6.0
This article was previously published under Q191737 SYMPTOMS
DAO applications that use a Microsoft Access .mdb file on a read-only media
(CD-ROM, floppy disk write protected, a hard disk that is read only to the
user, etc) must open the database file with exclusive access.
If you don't open the database exclusively, you get one of the following
errors when attempting to open a recordset:
- The Microsoft Jet Database engine cannot open the file
'YourMDBfile.mdb'. It is already opened exclusively by another user, or
you need permission to view its data.
- Couldn't Lock File
CAUSE
Jet requires the creation of a locking file (.ldb file) in order to open a
database file in shared access mode. If you request shared access mode, Jet
attempts to create the locking file, which fails on read-only media. If you
open a database using exclusive mode, Jet does not need to create the
locking file.
RESOLUTION
Open the database with exclusive access. One way to do this is to insert
the following three lines into the wizard generated RecordView
OnInitialUpdate as follows:
static CDaoDatabase mdb; //** Add db class here or in .h file.
mdb.Open("D:\\RO.mdb",TRUE,TRUE); //** RO && Exclusive
m_pSet->m_pDatabase= &mdb; //** Assign DB to RecordSet class.
Even though you must open the .mdb file with exclusive access, other
applications can also open it read-only and exclusive.
Modification Type: | Minor | Last Reviewed: | 8/11/2005 |
---|
Keywords: | kbDatabase kberrmsg kbprb KB191737 |
---|
|