c# – Connection string error – Sql Express
The top one is for a SQL data file connect thats located here: C:UsersWorkDocumentsVisual Studio 2015ProjectsMyTestMyTestDatabase.mdf
connectionString = Data Source=(LocalDB)MSSQLLocalDB;AttachDbFilename=C:UsersWorkDocumentsVisual Studio 2015ProjectsMyTestMyTestDatabase.mdf;Integrated Security=True;Connect Timeout=30;
The second is to a local database. Make sure the name of the sever localhost is correct. Also I noticed in your database name you have Databasen is this correct spelling. Check user name and password too.
connectionString = Data Source=localhost\SQLExpress;Initial Catalog=Databasen;User ID=admin;Password=password;
Please explain what you are doing when you say
But when inserting this string path in my button in Form1, and press button, an error appears – couldnt open connectionSystem.Data.SqlClient.SqlException (0x80131904)
You should never put the connection string in your user interface.
If you need to know how to connect through code we can show you.