My application cannot update Access database after deployment to “C:\Program Files\…”

后端 未结 1 564
粉色の甜心
粉色の甜心 2020-12-04 02:35

I have deployed my application to be ready for use by another user (another computer), but when I try to add the data to the database I get the error

相关标签:
1条回答
  • 2020-12-04 03:33

    When a Visual Studio application is under development it resides in a folder to which the developer has read/write access. This is obviously necessary since the developer needs to be able to edit the source code files. If you place a database file "in with the code" then the application can update the database file because it is in a "writable" location.

    However, if on deployment the database file stays "with the code" and the installer puts the files (i.e., the executable file and the database file) into %ProgramFiles% on the target machine (for example, C:\Program Files\MyApplication) then the average user will not have write access to that location. Files in %ProgramFiles% are normally restricted to read-only to protect the system from malware.

    Some people will try and configure the installer to grant write access to normal users for some file(s) or folder(s) under %ProgramFiles% but that is a Bad Idea™. The installer should really copy the database file to a location that is normally read/write for the intended user(s): either %USERPROFILE% (for a specific user), or %PUBLIC% (for all users).

    0 讨论(0)
提交回复
热议问题