I want to write into Access Database File using C# Application, probably using WPF ... I also want the file to be password protected ... is it possible to connect to it while it is password protected or should I remove the password?
+1
A:
Yes you can work with a password protected MS Access Database.
In your connection string to MS Access database, you can provide a USERNAME
and PASSWORD
.
Depending on which Security type is implemented, here are two samples:
Workgroup Security using a System Database
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Server\Share\MyData.mdb;Jet OLEDB:System Database=\\Server\Share\MyData.mdw;USER=userid, PWD=password"
With Standard MS Access Security:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Server\Share\MyData.mdb;User ID=userid;Password=password;"
Raj More
2010-07-12 12:28:38
@Raj More: I would like to see a code for the connection, write process and read process if possible
sikas
2010-07-12 12:29:39
The difference between your two examples is that the first specifies a workgroup file while the second will use whatever is defined as the default workgroup file for that version of Jet on that particular computer.
David-W-Fenton
2010-07-13 20:32:42
@David-W-Fenton That's right. In addition to using whatever the default workgroup file suggests, it will also use the login info for that particular MDB, right?
Raj More
2010-07-14 11:51:24
If you don't specify one of the arguments, it will use the defaults. For workgroup, that's whatever is set as the default workgroup file. For username, it's admin, and for password, none.
David-W-Fenton
2010-07-14 18:41:05
+2
A:
Use OleDbConnection (System.Data.OleDb) and the right connection string.
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;User Id=admin;Password=;
Arthur
2010-07-12 12:29:40
OleDb conn = new OleDb("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;User Id=admin;Password=;"); ... can I set the data source to something like Data Source=mysource; ?? but for the username, what will it be? as the access takes password only to lock the file ...
sikas
2010-07-12 12:34:48