Search code examples
c#sqldatabasems-accessoledb

Make MS-Access database file accessible to C# program from LAN network


I have a C# program that connects to MS-Access local file using:

dbConnection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + sPath);
dbConnection.Open();

where sPath is the local file path.

The program does select, insert and update sql operations. I want to deploy the C# program to another computer wih is on WiFi LAN to access the same database. I assume I only have to provide correct Path? or anything else? Will the database allow both read and write operations?


Solution

  • RE: sharing the database over the network

    Yes, essentially all you really need to do is put the .accdb (or .mdb) file in a shared folder and tell your C# program where to find it.

    Notes:

    1. Each machine needs to have its own copy of the Access Database Engine installed. If Access is not already installed on the machine then you can download the Access Database Engine installer here.

    2. For multiple concurrent users to access the database all users must have sufficient privileges to create and modify the associated .laccdb (or .ldb) lock file in the folder where the database file resides. That is, all users need more than just read access to the folder. (That is a common mistake people make when they first deploy an Access back-end for multiple concurrent users.)

    RE: WiFi

    The ACE/Jet database engine relies on a solid network connection to the database file, so any intermittent network glitches resulting from a weak WiFi signal are going to cause problems. In the early days of WiFi that was a common cause of errors in many database applications (including, but not limited to, Access databases). WiFi technology has improved over the years, so this is less of a problem than it used to be, but do be aware that flaky WiFi can cause errors (and even corrupt the database file if you are unlucky).