我無法從Visual Studio 2010 Express連接到本地SQL Server 2008 R2試用版。無法連接到SQL Server 2008 R2
當添加一個新的連接,我瀏覽到這個位置的數據庫文件:C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\AdventureWorks_Data.mdf
,我遇到這樣的錯誤:
Could not open new data base 'C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL10_50.SQLEXPRESS\MSSQL\DATA ADVENTUREWORKS_DATA.MDF'.CREATE DATABASE is aborted. An attempt to attach an auto-named database for file C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA AdventureWorks_Data.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. File activation failure.The physical file name "C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\AdventureWorks_Data_log.ldf" may be incorrect. The log cannot be rebuilt when the primary file is read-only.
之間的人一個瘋狂的猜測 - 我認爲你得到一個錯誤,因爲你使用已經加載在SQL Server中的附加數據庫設置連接。試試這個:在通過Visual Studio添加新連接時,在選擇數據源的第一個屏幕上,選擇「Microsoft SQL Server」而不是「Microsoft SQL Server數據庫文件」 – 2012-02-20 02:10:35
感謝您的答案。我確實將數據庫文件加載到SQL Server中。在添加數據源的Visual Studio上,我只有3種選擇:Microsoft Access數據庫文件,Microsoft SQL Server Compact 3.5和Microsoft SQL Server數據庫文件。 – user1220000 2012-02-21 04:51:51
謝謝你的答案。我確實將數據庫文件加載到SQL Server中。在添加數據源的Visual Studio上,我只有3種選擇:Microsoft Access數據庫文件,Microsoft SQL Server Compact 3.5和Microsoft SQL Server數據庫文件。數據提供者是SQL Server的.Net框架數據提供者。 – user1220000 2012-02-21 04:59:50