I've made connection string in app.config and used it whenever I needed to make a SQL connection using this code:
static string connectionString = ConfigurationManager.ConnectionStrings["name"].ConnectionString;
It works perfectly if I use full path to the database but I want to make it universal (so I could install my application on any other PC) and I used |DataDirectory|
like this:
connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Biblioteka.mdf;Integrated Security=True"
After using |DataDirectory|
, I can access the database (I'm not getting any errors while debugging) through my app but I cannot update it, delete records from tables etc...
Is there a way I can keep using app.config for connection string and making it universal at the same time?