How to Open a Password encrypted .accdb file in Access 2007 using


G

Guest

I'm trying to open a password encrypted file using vb. I've always used DAO
and as far as I can understand it, you need to use ADO for this feature. I
can open the Database OK directly from Access after entering the password
(1234)


From the Access help I think this should code work:

Dim Cnnct1 As ADODB.Connection
Dim sUser As String

sUser = CurrentUser() 'The cuurent user is Admin

Set Cnnct1 = New ADODB.Connection
Cnnct1.Provider = "Microsoft.Jet.OLEDB.4.0"
Cnnct1.Open "c:\Test1.accdb", "Admin", "1234"


But I get an error that the workgroup information file is missing - which
seems a bit odd as I thought that the new encryption scheme made all that
obsolete.

Can someone please give me a hint?

Cheers

IanO
 
Ad

Advertisements

S

Scott McDaniel

I'm trying to open a password encrypted file using vb. I've always used DAO
and as far as I can understand it, you need to use ADO for this feature. I
can open the Database OK directly from Access after entering the password
(1234)


From the Access help I think this should code work:

Dim Cnnct1 As ADODB.Connection
Dim sUser As String

sUser = CurrentUser() 'The cuurent user is Admin

Set Cnnct1 = New ADODB.Connection
Cnnct1.Provider = "Microsoft.Jet.OLEDB.4.0"
Cnnct1.Open "c:\Test1.accdb", "Admin", "1234"

You're using the wrong Provider:

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Persist Security Info=False;

From www.connectionstrings.com

Scott McDaniel
[email protected]_infotrakker.com
www.infotrakker.com
 
G

Guest

Scott McDaniel said:
You're using the wrong Provider:

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Persist Security Info=False;

From www.connectionstrings.com

Scott McDaniel
[email protected]_infotrakker.com
www.infotrakker.com
Thanks Scott,

Following your advice I changed my test code to :

Set Cnnct1 = New ADODB.Connection
Cnnct1.Provider = "Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Test1.accdb;Persist Security Info=False;"
Cnnct1.Open "c:\Test1.accdb", "Admin", "1234"
Cnnct1.Open

Unfortunately the same error message appears which is in full:

Run-time error '-2147217843 (80040e4d)'

Cannot start your application. The workgroup information file is missing or
opened exclusively by another user.

Any other thoughts?

Many thanks

IanO
 
J

Joan Wild

The accdb format does not support user level security, so you shouldn't be referring to a mdw or username/password. I believe you need the syntax to open the database with just the database password. Check the www.connectionstrings.com link again.
 
G

Guest

I've found a solution! I've listed it here for the benefit of other 'ADO
virgins' who no doubt will have the same problem.

In my example, the file Test1 is located in the c:\AccessTemp directory,
with the default username (which isn't case sensitive) of 'Admin' protected
by password '1234'

First I would recommend using this syntax, which allows step by step
debugging:

Dim Cnnct1 As ADODB.connection

Set Cnnct1 = New ADODB.connection

With Cnnct1
.Provider = "Microsoft.ACE.OLEDB.12.0"
.Properties("Data Source") = "C:\AccessTemp\Test1.accdb"
.Properties("User ID") = "Admin"
.Properties("Jet OLEDB:Database Password") = "1234"
.Open
End With

This works! I found the connection string at www.connectionstrings.com as
suggested by Scott McDaniel.

The bit that is missing from the examples is the 'Jet OLEDB:' without this
you get the misleading message:
'Cannot start your application. The workgroup information file is missing or
opened exclusively by another user. '

'Jet OLEDB:' is referred to at this location:
http://msdn2.microsoft.com/en-us/library/aa141406(office.10).aspx

If you use "Microsoft.Jet.OLEDB.4.0" as the provider an 'Unrecognized
Database Format' error appears

If anyone finds this helpful you can buy me a virtual drink!

IanO
 
Ad

Advertisements

G

Guest

Ian,

I have been having a similar problem to yourself but when I try the solution
below I receive a message that dbconn is read only.

dbconn=New OleDbConnection
With dbconn
.Provider = "Microsoft.ACE.OLEDB.12.0"
.Properties("Data Source") =
Server.Mappath("\fpdb\ContactDetailsP.accdb")
.Properties("User ID") = "Admin"
.Properties("Jet OLEDB:Database Password") = "test"
.Open
End With

I then tried to create as the following string:

dbconn=New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source="
& Server.Mappath("\fpdb\ContactDetailsP.accdb")&";User ID = Admin; Jet
OLEDB:Database Password=test;")

This compiles okay but I receive a message that the password is invalid. The
password of test is correct - I can open the database on my PC using it.

Just checking that your solutioon is working okay and if it is deployed on
the web.

Also I am not sure where the user id is set as Access 2007 doesn't offer
this as an option when encrypting and password protecting the Db.
 
Ad

Advertisements


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