简体   繁体   中英

Cannot attach database created in VS2010 to SQL Server studio 2008 r2

I have created a database in VS2010 C# which I would like to attach to SQL Server 2008 R2 so that I can use the import wizard to import data from an Excel file for each table.

However, when I try to attach the .mdf file from docs/vs2010/projects/... etc I cannot select this in the SQL Server Management Studio window (see screenshot).

It will only let me select .mdf files from the SQL Server Management Studio 2008 program files location.

Any help is much appreciated, thanks.

img:

http://i1186.photobucket.com/albums/z373/barbsbargainsltd/q3_zps127dd713.jpg

Try to copy the .mdf file from

docs/vs2010/projects/... etc

to the SQL Server Management Studio 2008 program files directory and then connect it again. If it does not allow to copy, detach database in options of VS, then copy.

从屏幕截图很难分辨...在对话框中,您既可以浏览,也可以手动键入文件的路径(包括网络资产的UNC路径),也可以将文件复制到该位置。还是要好一些,因为那么所有的.mdf文件都放在一个位置。

通常情况下,您需要将mdf文件复制到SQL Server的数据文件夹中(即C:\\ Program Files \\ Microsoft SQL Server \\ MSSQL10_50.SQLEXPRESS \\ MSSQL \\ DATA)。下一步,您需要附加此文件从sql server窗口访问数据库。确保您的数据库文件扩展名为.mdf

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