Connecting to an Access Database

BlueJay924

Well-known member
Joined
May 6, 2003
Messages
46
i need some help trying to connect to an access database. For a while now Ive been using vb.net, and ive had no problem connecting to a database. The reason ive had no problem is because i havent been using a password. its when i protect the database with a password is when i cant connect. What ive been doing so far is opening the database with open-exclusive, and from there i set the password. I assumed that this code would work:

cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C:\databaseToOpen.mdb;password = thePassword")
cn.Open()

but so far no luck. Is it even possible with only a password? If so, what am i doing wrong.

Evenutally id like to be able to add new users/passwords, but still having problems. Any kind of tutorial for this would be really helpful.
 
I tried your sample code, but all i got was this message:

"Cannot start your application. The workgroup information file is missing or opened exclusively by another user"


Even when i set the id as administrator and password as null, i still get the same message. This is a portion of what i have:

strPath = "c:/nameofdatabase.mdb"
strPassword = "thePassword"

Dim Connection As String "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPath & ";Jet OLEDB:Database Password=" & strPass & ";User ID=username;Persist Security Info=True"

Try
Dim cn As New OleDbConnection(Connection)

cn.Open()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try

What am i doing wrong?
 
Thanks for the help. I did solve my problem. I had to add
"Jet OLEDB:System database=C:\Secured.mdw;" into the connection string. Everything works fine. thanks again.

I do have another question though. What is the difference between using Password and Jet OLEDB:Database Password? I can use Password but not Databse Password.
 
Back
Top