简体   繁体   中英

How do I include my SQLite database in my published vb.net project?

I have been working on a project in vb.net which uses an SQLite database (Patient_Database.db). The connection between the software and the database works when I debug the program, and the database is stored in the project folder, and automatically transferred to the debug folder, as shown:

解决方案资源管理器中的数据库

调试文件夹中的数据库

However, when I publish the project in order to make an executable, the database is not included in the publication. I have spent all day trying various walkthroughs online but I just don't seem to be able to get the publication to include the database or the necessary SQLite.Interop.dll file in the x64 and x86 folders in the Debug folder.

My published project looks like this:

出版物

With the following inside the Application Files folder:

在此处输入图片说明

I realise that I might be doing something stupid, or that I might just be going about this in the entirely incorrect way. If anyone could correct my flawed methods that would be very helpful!

Thanks

In regards to the comments some visual help for you:

将数据库添加到已发布文件1

  1. Open project properties of your main project
  2. Select the Publish tab
  3. Choose Application files...

将数据库添加到已发布文件2

  1. Find your db file
  2. If it is not listed, select Show all files first
  3. Set the Publish Status to Include
  4. The Download Group should be Required .

After a new publish the DB file should be contained in the Application Files on your server.

EDIT: To make the file visible for the published application files you have to set its 'Build Action':

使DB文件可用于发布

在此处输入图片说明 Just add a folder "Database" in your project and insert there your file.db

Then on Publish "Application files" include as dataFile your file.db

在此处输入图片说明

在此处输入图片说明

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