How to open password protected Access database?

Hi, I want to open a password protected MS Access file from VB. How can I do that without using ODBC.
Waiting for help...
MoinAsked:
Who is Participating?
 
azupancicConnect With a Mentor Commented:
In order to open a password protected database via DAO, you need to supply all the information in the connect string when you open the database.  The connect string is semi-colon delimited, but what help doesn't tell you, is that even though Access is the default db type, you don't supply that portion of the connect string, i.e, you omit it, thus beginning your connect string with a semi-colon.

The sample below illustrates this:

Set db = OpenDatabase("MyDB.MDB", False, False, ";pwd=password")

Hope this helps.
0
 
watyCommented:
  DBEngine.SystemDB = "C:\yoursystemmdw.mdw"

   'Create a new workspace object
   'gwWorkSpace is a Global variable where you put in the module
   'txtUserName and txtPassword are fields on Logon screen.
   '
   Set gwWorkSpace = DBEngine.CreateWorkspace("New", _
   Trim(txtUserName.Text), Trim(txtPassword.Text), dbUseJet)

0
 
MoinAuthor Commented:
I can't understand your answer. What if I don't want to use workspace and if I am opening database directly using opendatabase. e.g.,
set godbHMC = opendatabase(dbPath)
How can I do this.

0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
watyCommented:
When you open directly your DB, you use a default workspace.

You have to create a workspace other than the default, with only the password.
0
 
MoinAuthor Commented:
But I have just password protected the database, I have no userName for the database.
0
 
watyCommented:
In that case I think you have to use the default user (probably admin). Otherwise, create a user.
0
 
soedingCommented:
Answer also to me, please.
0
 
MoinAuthor Commented:
My problem is still unsolved. Please tell me in detail ad each and every step to do this.
0
 
watyCommented:
First : Create a user in your Access DB with a password :
         User     = "BillClinton"
         Password = "Monica"

Second : You have to create an new workspace :
   DBEngine.SystemDB = "C:\yoursystemmdw.mdw"

   'Create a new workspace object
   Set gwWorkSpace = DBEngine.CreateWorkspace("New", _
   "BillClinton", "Monica", dbUseJet)

Third : Open your database :
   set godbHMC = gwWorkSpace.opendatabase(dbPath)
 

0
 
MoinAuthor Commented:
When I use your suggested answer, I get the error
"Can't start your application. The workgroup information file is missing or opened exclusively by another user."
In my case none of the above situation exists.
What should I do now?
0
 
watyCommented:
Wich version of Access do you use? If it is access 2.0, it is a MDA file.
0
 
MoinAuthor Commented:
It is Access 97.
0
 
watyCommented:
Is your .MDW file exists?
0
 
MoinAuthor Commented:
Yes it exists in "C:\winnt\system32\system.mdw"
0
 
MoinAuthor Commented:
Yes it exists in "C:\winnt\system32\system.mdw"
0
 
watyCommented:
Are you sure that Access is not open when you test your application?
0
 
MoinAuthor Commented:
yes, it's not open
0
 
MoinAuthor Commented:
Yes, that's great.
0
All Courses

From novice to tech pro — start learning today.