简体   繁体   中英

WPF Desktop app how to include a sqlite DB

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

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

It sounds like you want to have your SQLite database included in your project output including all the records that were added (ie 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM