0

When I attempt to either save data entered from a text box to my DB, or search through data in my DB I am presented with an error message of:

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 C: \Users\User\Documents\Visual Studio 2015\Projects\Aaron's WPF Project\Database1.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

I deleted my database, re created it, and re entered the connection string but I'm still presented with this error? Why's this.

Here is my connection string:

 SqlConnection Connection = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C: \Users\User\Documents\Visual Studio 2015\Projects\Aaron's WPF Project\Database1.mdf;Integrated Security=True");
Aaron G
  • 7
  • 4

1 Answers1

0

I just spent a frustrating hour trying to figure this out. Turns out it's a normal exception thrown inside the .NET SqlClient library, and I could just ignore it and it would continue on and work just fine after that.

Dylan Nicholson
  • 1,301
  • 9
  • 23