Ive created a new project and added a database which is saved locally on the C drive. When running the program i can see the data displayed however when im trying to search (click button) for a certain ID number it throws up an exception
The code i entered so far is below
private void button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=(LocalDB)\\v11.0;AttachDbFilename=\\ox15156\\c$\\Users\\LLOYDJ\\Documents\\WindowsFormsApplication1\\WindowsFormsApplication1\\Database1.mdf;Integrated Security=True");
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter ("select * from Table where Id like = "+ int.Parse(textBox1.Text), conn);
sda.Fill(dt);
dataGridView1.DataSource = dt;
The error shown is
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: An attempt to attach an auto-named database for file \ox15156\c$\Users\LLOYDJ\Documents\WindowsFormsApplication1\WindowsFormsApplication1\Database1.mdf failed. A database with the same name exists, or specified file cannot be opened,
or it is located on UNC share.
Can anyone please help