Connect to password protected database

torhan
10-27-2004, 02:22 AM
Hello!
How do I connect to an access database that is password protected? I'm not using user level sequrity, only the database is protected from opening.

The following code generates an error "Wrong password". If I include the password in the connectionstring the error is "Can't find sequrity file" or something like it.

Public cn As ADODB.Connection

Public Sub ConnectToDatabase()

Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & _
strDBPath & "db1.mdb;"

cn.Open
End Sub

Flyguy
10-27-2004, 03:29 AM
Maybe this can be of any help:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/adoproperties.asp

torhan
10-27-2004, 05:13 AM
Thank you!
The solution was:

cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & _
strDBPath & "db1.mdb;Jet OLEDB:Database Password=drowssap"

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum