I'm using old DAO 3.6 to connect Access database (with mde extension). App works fine on XP and on Win7/Vista when UAC is low/disabled. But when UAC is on I get following error:
The Microsoft Jet database engine cannot open the file 'C:\\ProgramData\\company\\db.mde'. It is already opened exclusively by another user, or you need permission to view its data.
My code:
'Connect to Database
dbE = New DAO.DBEngine()
dbT = dbE.OpenDatabase(Environment.GetFolderPath(
Environment.SpecialFolder.CommonApplicationData) & "\company\db.mde")
By default, Access databases are opened read-write. Also by default, regular users don't have write permissions on C:\\ProgramData
. Since, when UAC is enabled, you are just a "regular user", it won't work. To fix this, you have the following options:
or
C:\\ProgramData\\company
so that regular users may modify files. or
Open the database in shared read-only mode. That way, DAO does not require write permissions to the file ( readonly ), nor does it require permissions to create an ldb file ( shared ).
dbT = dbE.OpenDatabase(Environment.GetFolderPath( Environment.SpecialFolder.CommonApplicationData) & "\\company\\db.mde", True, True)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.