?
Solved

Using a password protected access database

Posted on 2006-06-26
5
Medium Priority
?
217 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 375 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

800 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