I'm trying to connect a table database I created within Visual Studio and used the connection string, but keep getting a bunch of errors? I need to do this multiple times but can't even get the first one to work + im not sure what's wrong
this is the line of code I've used:
CSharp SqlConnection Con = new SqlConnection(
@"Data Source=(LocalDB)\MSSQLLocalDB;
AttachDbFilename="C:\Users\scara\Documents\nea2022 database.mdf";
Integrated Security=True;
Connect Timeout=30");
I've connected through the tools tab and "connect to database" and it said that it was successful, so I'm really not sure ://
AttachDbFilenameis a really bad idea, it will cause copies to be made of your database, which are deleted when you close the connection. Just attach your database normally. Also you should keep your connection string in a settings file, which would have prevented this error in the first place