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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I Need Help Connecting to My MDB in VB 1

Status
Not open for further replies.

dotnetprogrammer

Programmer
Aug 17, 2000
77
0
0
US
I need to connect to a password protected MS Access database, using ADO. This is the open connection string I am using (nothing unusual):
myConnection.Open “c:\database.mdb”, "admin", "myadminpassword"
When I try to open the Access MDB file, VB generates error message as follows:
"Run time error ‘-2147467259 (80004005)’:
Can’t start your application. The workgroup information file is missing or opened exclusively by another user."

The database is on the local drive and hasn’t been not opened by anyone. If I remove the password from the databases it works just fine. But the problem is I must have the password protection. How can I connect to this database without using DSN or WRKGADM.EXE.
Your help will be greatly appreciated!
-fred
 
Try this connection string. You can change the provider to 3.5 if you do not have 4.0 installed.

myConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" &_
"DATA Source= C:\database.mdb;" & "USER ID= admin;" & _
"Password= myadminpassword"

David Paulson


 
Just tried your suggestion, and I am still getting the error with a different error code. The info on the message box is as follows:

"Run time error '-2147217843 (80040e4d)':
Cannot start your application. The workgroup information file is missing or opened exclusively by another user."

The database hasn’t been opened by anyone, positive. If I remove the password from the database (AND from the connect.open string) it works just fine. But the problem is I must have the password protection, and I cannot ask users to setup their DSN or their workgroup information file (WRKGADM). If I have to do it, I have to do it programmatically. What is the best approach, and do I get there?

Again, thank you for your help!
 
This will work:
dbPatch="C:\MY DOCUMENTS\MYDATABASE.MDB
Passwd="MyPassword"
Set cn = New ADODB.Connection
With cn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & dbPatch & ";" & _
"Persist Security Info=False;" & _
"Jet OLEDB:Database Password=" & Passwd
cn.Open
End With
If You use Dataenvironment Designer click ADVANCED tab,
Click EDIT and for DATABASE PASSWORD put Your Password.
 

I've connected using this method:


ChDir "C:\"

openString = "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=database.mdb;" & _
"DefaultDir=C:\;" & _
"Uid=Admin;Pwd=yourAdminPasswrd;"


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top