简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM