Opening a read only file

B

Brad Wood

Closest related newsgroup I could find...

I am using DAO to programmatically create an access database, close it, set
the file properties to read only, and re-open it.

Upon attempting to reopen the database after making it read only, I get the
Jet access error "Jet database engine cannot open the file" ... "it is
already opened exclusively" ...

If I attempt to open the same file directly with Access, I get the error
"database or object is read-only." If I remove the read only property from
the file and open it in Access, it opens fine. If I make the file read only
again and open it directly in Access it opens fine (in read only mode).

I hope somebody has some idea why the file is in such a weird state when I
set it read only programatically. Note: this is unrelated to MS KB article
191737 - Access / DAO is able to create a .ldb file in the same folder.
 
B

Brad Wood

That's basically what I'm doing (I'm using Delphi, but the DAO components
are the same). The only difference is that I am adding a table. If I set a
breakpoint where I'm about to set the file read-only, open the database
directly with Access, and then let my code continue, everything is fine.

Maybe something needs to be initialized or something? I have tried opening
the table after creating it. It all seems fine, but still the file is
un-openable after I set it read-only.
 
B

Brad Wood

Once the database is created and set to read only, it's hosed until I turn
read only off. Access won't open it any any mode.

Dev Ashish said:
Are you specifying the "Options=false" argument? Without it, OpenDatabase
might be trying to use "Exclusive" mode to open the database, resulting in
the error. You can verify this from Access by selecting the "Exclusive"
option in the File|Open dialog.
 
B

Brad Wood

It wouldn't prove helpful since I am using DAO components for Delphi. In
fact, it may be something specific to those components. The code is simple
and I ensured that I'm not leaving any open connections / references. I'll
have to move on...

Dev Ashish said:
I would suggest posting your code here as the VBA function I'd posted
works. It almost sounds like that the reference to the db is not being
cleared or you are trying to create a 2nd connection w/o closing the 1st one
(which might be exclusive).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top