I have a connection string set in my App.Config
<add name="project.Database.Database"
connectionString = "Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\User\Desktop\Project\Database\Database.mdf;Integrated Security=True"
providerName = "System.Data.SqlClient" />
I access the database like this:
private static string ConnectionString = ConfigurationManager.ConnectionStrings["Database.Database.sfd"].ConnectionString;
//Open the connection and check if the reader has found any rows of data.
using (this.SqlCon = new SqlConnection(ConnectionString))
using (SqlCommand cmd = new SqlCommand(query, SqlCon))
{//blahh}
it works perfectly however, when i use it on another PC etc it doesnt work as i have hard coded the connection string to a certain location.
How can i make it so that at startup the connection string is set to the current location of the database.
Thanks all