有園子里的朋友問到一個問題:系統上安裝的是vs2008+Sql 2005 developer(沒有安裝Sql server 2005 Express ) 用代碼直接連SQL Server服務器沒有問題,但在項目中數據源改用SQL Server數據庫文件時出錯,提示錯誤如下: “與SQL Server文件(*.mdf)的連接要求安裝SQL Server2005才能正常工作,請確認是否安裝了該組件,……” 英文版為“Connections to SQL Server Files (*.mdf) require SQL Server Express 2005 to function properly. Please verify the installation of the component or download from the URl: http:go.microsoft.com/fwlink/?linkID=49251.”
如圖:
如果是因為實例名的問題,請先查看這個
http://www.companysz.com/article/31647.htm
我機器上裝的是Vs2008 Team suite Sp1+sql server 2008 enterprise,嘗試配置連接SQL Server數據庫文件時出錯同上圖。 奇怪,難道數據庫連接方式必須安裝SQL server 2005 Express?? 查看msdn等,沒有看到有此限制, http://www.microsoft.com/china/sql/prodinfo/features/compare-features.mspx http://technet.microsoft.com/zh-cn/library/ms143761%28SQL.90%29.aspx 也看到有些文章 http://social.msdn.microsoft.com/Forums/en-US/sqlsetupandupgrade/thread/6503fe05-4d05-49e7-8c2a-b9778ab7e9b8
最后抱著試一試的想法,看看是否是因為數據庫已附加到SQL server , 嘗試將示例文件,AdventureWorksLT2008_Log.mdf脫機 (注示例文件官方下載http://www.codeplex.com/Wiki/View.aspx?ProjectName=SqlServerSamples) 再連接,居然成功了!