1

I am developing a WPF desktop application that uses a SQLite DB and this is in my App_data folder which is fine while a run it in debug but how do i include a DB file when i build my application and run it on another computer? do i need to build an installer for my app to create a copy of the DB in a location on the users machine that has read/write access?

Thanks

Andrew
  • 71
  • 4
  • 1
    Yes, this location is usually on Windows7/8: `C:\ProgramData`. You create your app folder there for the SQLite database. In your code refer to your database from here: `Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)` – Cristina Alboni Apr 03 '15 at 15:00

2 Answers2

1

You could create the database in your initialization routines if the database doesn't exist. You can include the location and other settings in your app config. Check this link out: Create SQLLite Database and Table

Community
  • 1
  • 1
Dusty Lau
  • 591
  • 4
  • 18
1

It sounds like you want to have your SQLite database included in your project output including all the records that were added (i.e. you do NOT want to deploy an empty copy of the database, but rather the same data that you were working with during development).

To accomplish this, add the SQLite database to your project and set the build action to "copy to output location". In your config file, you can then set up the connection string to look for the file in the application directory.

Now, every time you build the project, a fresh copy of the database will be placed in the output directory.

user700390
  • 2,287
  • 1
  • 19
  • 26
  • 1
    Yes i want to add in some reference data that my application will use and also the application will save user inputed data back to this database. – Andrew Apr 03 '15 at 15:30