(Leo) ADO Connection Error

G

Guest

Hi,
I have an Access mdb file with exclusive file password. From Excel I attempt
to connect to the file, it produces Automation Error no -2147217843.
the code looks like this;
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open "C:/DB.mdb", "Admin", "MyPassword"
End With
when I remove the password from my mdb file it works well.
Why? Is there a difference between the connection string password and mdb
file password?
if So, how can I principally make a connection with mdb file with password?
 
B

Brendan Reynolds

The database password is separate and distinct from any user-level password
that may be applied, yes. Here's an example of a connection string that
includes a database password ...

Const strcConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"User ID=Admin;Data Source=c:\usenet\passtest.mdb;" & _
"Persist Security Info=False;Jet OLEDB:Database Password=Whatever"
 
G

Guest

Thanks a lot....it worked great, though I can not analyse what each part of
the string mean.
--
Thans & Best regards
Leo, InfoSeeker


Brendan Reynolds said:
The database password is separate and distinct from any user-level password
that may be applied, yes. Here's an example of a connection string that
includes a database password ...

Const strcConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"User ID=Admin;Data Source=c:\usenet\passtest.mdb;" & _
"Persist Security Info=False;Jet OLEDB:Database Password=Whatever"
 
B

Brendan Reynolds

Provider=Microsoft.Jet.OLEDB.4.0; - You probably know this one, specifies
which provider to use.

User ID=Admin; - Not necessary if you're not using user-level security, as
'Admin' is the default. If you were using user-level security instead of or
in addition to the database password, you'd specify the user name and the
user password (not the database password) like so ... User
ID=SomeUser;Password=SomePassword;

Data Source=c:\usenet\passtest.mdb; - I'm sure you know this one, the path
and name of the data file.

Jet OLEDB:Database Password=Whatever; - The database password (not the user
password, see above). The 'Jet OLEDB:' prefix identifies this as a
JET-specific extended property rather than a standard OLEDB property.

Persist Security Info=False; - I won't try to explain that one myself.
Here's a link to an MSDN article that explains it instead ...
http://msdn2.microsoft.com/en-us/library/ms254499.aspx

--
Brendan Reynolds
Access MVP

Leo said:
Thanks a lot....it worked great, though I can not analyse what each part
of
the string mean.
 

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