I am trying to publish my c# project and I am worrying that if I publish it my connection to the database will not work once I install the project to another machine. Someone told me that I could use
and it seems not working for me Application.StartupPath
I have this connection string for my database
string connectionstring = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True";
and when I put the Application.startupPath
in the connection string like this
string connectionstring = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|"+Application.startupPath+"\Database1.mdf;Integrated Security=True";
it is not working