Link to home
Start Free TrialLog in
Avatar of ljhodgett
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("Users", 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
Avatar of Wadski
Wadski
Flag of United Kingdom of Great Britain and Northern Ireland image

Hi there ljhodgett,

Using the OpenDatabase command to open a passworded database is covered on this MS support article:
http://support.microsoft.com/?kbid=209953



Wadski
ASKER CERTIFIED SOLUTION
Avatar of JackOfPH
JackOfPH
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Although you should only need one Set dbMyDB line!
Avatar of hiteshgupta1
hiteshgupta1

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.OLEDB.4.0; Data Source=D:\mydatabase.mdb; Jet OLEDB:Database Password=mydatabasepassword"
        .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