I've got a problem with a project with Visual Studio 2017.
I want to save data in a local SQL Server database but when I run the script this error always happens at connection.open();
:
System.Data.SqlClient.SqlException: "An attempt to attach an auto-named database for file C: \Users\mrman\onedrive\dokumente\visual studio 2017\Projects\WindowsFormsApp1\WindowsFormsApp1\DB_Nährwertrechner.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."
Here's the code for the connection:
SqlConnection connection = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C: \Users\mrman\onedrive\dokumente\visual studio 2017\Projects\WindowsFormsApp1\WindowsFormsApp1\DB_Nährwertrechner.mdf;Integrated Security=True;Connect Timeout=30");
connection.Open();
Do you guys know why that error comes and how to solve it?