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
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).