password protect .mdb

SIMIN

Well-known member
Joined
Mar 10, 2008
Messages
92
I create a connection to my access database like this:
Code:
Dim StringConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + "C:\Access.mdb"
Dim MyConnection As New OleDbConnection(StringConnection)
MyConnection.Open()
...
MyConnection.Close()
The question is that how can I password protect this database file "C:\Access.mdb"?
Thanks.
 
To password protect the access data base you need to open it with Exclusive Use, then click tools, security and set password.

When that is done you need to changed your connection string to

Code:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Access.mdb; OLE DB Services = -4; Jet OLEDB:Database Password=[your password];";

Cant remember if the OLE DB Services = -4 is needed or not, long time since I used this :)
 
Back
Top