Solved

Using a password protected access database

Posted on 2006-06-26
5
207 Views
Last Modified: 2010-04-07
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
0
Comment
Question by:ljhodgett
5 Comments
 
LVL 16

Expert Comment

by:Wadski
ID: 16982613
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
0
 
LVL 15

Accepted Solution

by:
JackOfPH earned 125 total points
ID: 16982625
change it to this...

 Set dbMyDB = OpenDatabase(App.Path & "\db4.mdb", False, False, "MS Access;pwd=mypassword")
 Set dbMyDB = OpenDatabase(App.Path & "\db4.mdb", False, False, "MS Access;pwd=mypassword")

0
 
LVL 16

Expert Comment

by:Wadski
ID: 16982648
Although you should only need one Set dbMyDB line!
0
 
LVL 8

Expert Comment

by:hiteshgupta1
ID: 16983082
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!!
0
 
LVL 12

Expert Comment

by:jkaios
ID: 16990267
If you're using DAO:
  Set dbMyDB = OpenDatabase(App.Path & "\db4.mdb", , , ";PWD=mypassword")

If you're using ADO:
  See hiteshgupta1's example above
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now