connecting to password protected Access table
I have created a small table in Access97 and applied a password. I have then put an ADO control onto a form and used the connection builder to create the connection string. Using Jet3.51 Ole DB
Without the password in Access it connects, but with the password it does not.
I get an error "Test failed because of an error in initializing provider. Can't start your application. Workgroup information file is missing or exclusively opened by another"
Can anyone explain what is going on here and how I correct it.
Re: connecting to password protected Access table
Make your COnenction string include the Password option ;
Provider=Microsoft.Jet.OLEDB.3.51;Data Source='EnterDBPath';Mode=ReadWrite|Share Deny None;Persist Security Info=False;Jet OLEDB:Database Password='EnterPassword'
Work is necessary for man. Man invented the alarm clock.
Re: connecting to password protected Access table
I agree that should work - but it dosen't
I get an error password not valid
strDBuser = App.Path & "\Users.mdb"
Cn2 = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & _
strDBuser & ";Mode=ReadWrite|Share Deny None;" & _
"Persist Security Info=false;Jet OLEDB:Database Password='abcd'"
set wsUser = DBEngine.Workspaces(0)
'open database
set DBuser = wsUser.OpenDatabase(strDBuser, , , Cn2)
'open Users table
set rsUser = DBuser.OpenRecordset("UserData", dbOpenTable)
the Access data base is just three columns of data headed Name,Password and Initials
and I have used the Tools>security>set database password to set the password to abcd (all lower case). Still no joy !
Re: connecting to password protected Access table
Are you putting those single quotes in your Password as shown in your code below ?
Work is necessary for man. Man invented the alarm clock.
Re: connecting to password protected Access table
I put the single quotes in the connect string
but no quotes in the database password.
Note if I leave empty quotes in the connect string and set no database password it does work
but as soon as I put some characters in it fails
Re: connecting to password protected Access table
I think this is the problem have your tried it without, I have never used Single Quotes round my password and it works fine ?
Work is necessary for man. Man invented the alarm clock.
Re: connecting to password protected Access table
if I omit the single quotes I get the same result
Invalid password
Re: connecting to password protected Access table
I think it is a jet matter.
You should download jet driver from microsoft.com
(last version is not included in Mdac_typ.exe)
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
Re: connecting to password protected Access table
You are mixing DAO and ADO methods
it must be:
strDBuser = App.Path & "\Users.mdb"
Set cn2 = New ADODB.Connection
sConn = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & _
strDBuser & ";Mode=ReadWrite|Share Deny None;" & _
"Persist Security Info=false;Jet OLEDB:Database Password='abcd'"
cn2.ConnectionString = sConn
cn2.Open
'open recordset
Set rs = New ADODB.Recordset
sSQL = "select * from YourTable"
rs.Open sSQL, cn2, adOpenDynamic, adLockOptimistic
MsgBox "rs is open"
rs.Close
Set rs = Nothing
Set cn2 = Nothing
Iouri Boutchkine
[email protected]
Re: connecting to password protected Access table
Here is the way to connect to A password protected Access Database:
Dim cn as new ADODB.Connection
Dim Rs as new ADODB.Recordset
cn.Provider = "Microsoft.Jet.OLEDB.3.51"
cn.Properties("Data source") = "mydatabasepath" 'feg: c:\db1.mdb
cn.Properties("Jet OLEDB:Database Password") = "mypassword"
cn.Open
rs.open "select * from mytable",cn,adopendynamic
I use this code and it works!!