ljhodgett
asked on
Using a password protected access database
Hi Experts.
Im using the following to connect to an access database: -
Set dbMyDB = OpenDatabase(App.Path & "\db4.mdb")
Set dbMyDB = OpenDatabase(App.Path & "\db4.mdb")
Set rsMyRS = dbMyDB.OpenRecordset("User s", dbOpenDynaset)
I know its a crude way of connecting to the database but its easy. I'm trying to find out using the method above, how to connect to a password protected access database.
Many Thanks
Lee
Im using the following to connect to an access database: -
Set dbMyDB = OpenDatabase(App.Path & "\db4.mdb")
Set dbMyDB = OpenDatabase(App.Path & "\db4.mdb")
Set rsMyRS = dbMyDB.OpenRecordset("User
I know its a crude way of connecting to the database but its easy. I'm trying to find out using the method above, how to connect to a password protected access database.
Many Thanks
Lee
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Although you should only need one Set dbMyDB line!
Hi,
If you are setting the password through Tools->Security->Database Password, then try this:
With myConnectionObject
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties(15).Value = "mydatabasepassword"
.open "C:\mydatabase.mdb"
end with
Property #15 is Jet OLEDB:Database Password and allows you to call the database password!
you can include it in the connection string as follows:
With cnnConnection
.ConnectionString = "Provider=Microsoft.Jet.OL EDB.4.0; Data Source=D:\mydatabase.mdb; Jet OLEDB:Database Password=mydatabasepasswor d"
.Open
End With
Let us know if it helps u!!
If you are setting the password through Tools->Security->Database Password, then try this:
With myConnectionObject
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties(15).Value = "mydatabasepassword"
.open "C:\mydatabase.mdb"
end with
Property #15 is Jet OLEDB:Database Password and allows you to call the database password!
you can include it in the connection string as follows:
With cnnConnection
.ConnectionString = "Provider=Microsoft.Jet.OL
.Open
End With
Let us know if it helps u!!
If you're using DAO:
Set dbMyDB = OpenDatabase(App.Path & "\db4.mdb", , , ";PWD=mypassword")
If you're using ADO:
See hiteshgupta1's example above
Set dbMyDB = OpenDatabase(App.Path & "\db4.mdb", , , ";PWD=mypassword")
If you're using ADO:
See hiteshgupta1's example above
Using the OpenDatabase command to open a passworded database is covered on this MS support article:
http://support.microsoft.com/?kbid=209953
Wadski