Dmitry Makovetskiyd
Dmitry Makovetskiyd

Reputation: 7053

How do I attach a database in Visual Studio

I have a northwind.mdf file. I click on add existing file but it doesn't create an app_data folder. I also tried to add it from the server explorer, ADD connection --> connect to database--> test connection and I get:

"an attempt to attach an automated datebase for file (the path i take the file from) failed. A database with the same name exists or specified file cant be opened or it is located in unc share"

Basically, I can't get any connection string nor connect to the database in general.

Upvotes: 0

Views: 10214

Answers (1)

Kevin Cloet
Kevin Cloet

Reputation: 2976

An .MDF file is a database file for Microsoft SQL Server.

You will need to open SQL Management Studio and attach the .MDF file to the local SQL Server instance.

This will explain how to do it: http://www.kodyaz.com/articles/sql-server-attach-database-mdf-file.aspx

After it has been attached you can add the connection from Visual Studio.

Upvotes: 3

Related Questions