When I use server explorer in Visual Studio and add a local DB on my D drive, I get a connection string and the connection test is successful.
But when I want to use that connection string like below to attach the database without the wizard and jut by code, I get an error on opening the connection, my connection string is provided below:
string coonection_string ="Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\\x\book.mdf;Integrated Security=True;Connect Timeout=30";
try
{
SqlConnection myconnection = new SqlConnection(coonection_string);
myconnection.Open();
MessageBox.Show(" connected");
}
catch (Exception e1)
{
MessageBox.Show(e1.ToString());
}
D:\\...MessageBox.Show(e1.Message)