0

I tried searching the net for this probably simple answer, but without success. I have my WPF app almost ready - using connection strings to connect to my 3 databases (EnteralDB, ParenteralDB, PatientDB) that have several tables.

Problem is that it works while debugging because I hard wired the connection string to specific location (my desktop)

using (SQLiteConnection con = new SQLiteConnection(@"Data Source= C:\Users\Peter\Desktop\EnteralDB"))

But how I can I make the connection string "universal" - meaning that it will work when I create setup for the app and it will install on a new computer? How to embed the database files into the project so they are PART of the project itself and then somehow point with the connection strings to them? Thank you very much for help!

EDIT Actually, the comment by Clemens is correct. I changed the connection string to just the filename (EnteralDB.db), set copy if newer with content for the database properties and it is working

  • 1
    Set their *Build Action* to *Content* and *Copy to Output Directory* to *Copy ...*. Then the connection string should contain a relative path, i.e. only the file name. – Clemens Sep 10 '18 at 18:17
  • You should copy a seed database to a location the user has write access to and which will not be deleted when you repair the application; see [How to create database](https://stackoverflow.com/questions/32318584/). – Dour High Arch Sep 11 '18 at 00:15

0 Answers0