Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to conect to Access db with a password

Status
Not open for further replies.

qjd2004

Technical User
Feb 2, 2004
80
GB
Hiya,

trying to connect to an access db that is password protected. I get a runtime error that says "Cannot start your application. The workgroup information file is missing or opened exclusively by another user"

The db in question is not open and the workgroup file is not missing, it's where it belongs in Windows\System32\System.mdw

Can anyone help me overcome this, as I want to keep my end user out of the database if possible. I have a feeling it is because I'm not specifying which user to connect as, but I don't know how to do that. Some of my code:
Code:
Public Sub PopulateListBox(mdb As String)

Dim con As ADODB.Connection
Dim thisSQL As String
Dim ConnectionString As String
Dim rs As ADODB.Recordset
Set con = New ADODB.Connection

On Error GoTo BackOut

'Get the connection
    ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mdb
    con.Open ConnectionString, , "1811"
    con.BeginTrans

'Execute query to return as resultset
Set rs = con.Execute("SELECT DISTINCT DistID FROM qry_Output")
    
    rs.MoveFirst
        Do While Not rs.EOF
            UserForm1.UltimateListBox.AddItem rs.Fields("DistID")
            rs.MoveNext
        Loop

    con.CommitTrans
    con.Close
Exit Sub

Backout:
etc etc
Can anyone assist?
 
Your connection string needs to include the password:

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\dbase.mdb;Persist Security Info=false;Jet OLEDB:System Database= myDatabase.mdb;Password=WhateverPassword;User ID=WhateverUsername"

BB
 
Hiya,

no that doesn't work. I'm using this con string:
Code:
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mdb & _
  ";Persist Security info=False;Jet OLEDB:" & _
  "System Database=system.mdw;" & _
  "Password=pw;User ID=Admin"
But I get either workgroup information missing or opened exclusively by another user message.

I'm included to believe it as the system.mdw file has a little key next to it (as to access lock files) but I don't know how to unlock it.

Can you suggest anything?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top