Sql connection.open () exception

I am new to .net and in this I am working on a Windows Form application. I am trying to connect my application to a database based on Visual Studio. I just write the code for the submit button.

private void button1_Click(object sender, EventArgs e)
{
     SqlConnection con = new SqlConnection("Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\\Users\\mudasir\\Documents\\Visual Studio 2012\\Projects\\Medical_Store_System\\Medical_Store_System\\MSS_database.mdf;Integrated Security=True");
      con.Open();
      if (con.State == ConnectionState.Open)
      {
          textBox1.Text = "Congrats";
      }
      else
          textBox1.Text = "Sorry";
          con.Close();
}

On con.open (); I met with an exception that shows

"A network-related or specific instance error occurred while establishing a connection to SQL Server. The server could not be found or is unavailable. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (Provider: Named Pipes provider, error: 40 - failed to open connection to SQL Server) "

Please give me a simplified answer and solution, because I am new to these things.

+3
source share
1 answer

\ , \ (LocalDB)\version. .

SqlConnection con = new SqlConnection("Data Source=(LocalDB)\\v11.0;AttachDbFilename=C:\\Users\\mudasir\\Documents\\Visual Studio 2012\\Projects\\Medical_Store_System\\Medical_Store_System\\MSS_database.mdf;Integrated Security=True");
+3

All Articles