Search code examples
wpfsqlitesystem.data.sqlitesetup.exe

Integrating SQLite with a Windows application


So I created a simple WPF application that allows a user to INSERT a string into a SQLite database (a .S3DB file). The user can also SELECT a string from the database and DELETE the string from the database...very simple application.

I want to distribute this simple application, so I've created setup.exe file for the application by creating a new project and using the setup wizard on VS2010. When the user installs the application, it creates a "TestDatabase" folder in the Program Files directory and adds these two files along with the .exe file:

  1. System.Data.SQLite.DLL file (since it's a Detected dependency)
  2. TestDatabase.s3db file (A test database for the user to use)

When I install it on the computer I'm developing on...everything works. However, when I install it on another computer, it crashes when I try to open the database from the application (which is stored in C:\Program Files (x86)\TestDatabase\TestDatabase.s3db).

I was wondering if someone can help solve this problem? Thanks.


Solution

  • I realized that the reason why it was crashing when I opened the database is because I didn't install the setup package on the new computer I was testing on. The setup package includes all the runtime components and dependencies. The setup packages can be found here:

    http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki

    Also, ravenspoint, RandomEngy, and bryanbcook...you guys were right. Reading/writing a database from the Program Files folder is a bad idea because of the permission problem that can occur when accessing the database from the Program Files folder. So I saved my database in the AppData folder where the database can be read/written without any permission problems.