`
ihuashao
  • 浏览: 4515366 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

VS2008连接SQL Server数据库文件出错的解决方案(downmoon)

阅读更多


有朋友问到一个问题:系统上安装的是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.cnblogs.com/downmoon/archive/2007/12/29/1019264.html

我机器上装的是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)
再连接,居然成功了!

连接过程如图:
















需要注意的是:
脱机后,改用mdf文件直接连接,原来的逻辑文件AdVentureworksLT08.mdf对应的log文件自动失去关联,而产生了一个新的log文件,你可以关注一下数据库具体的位置,是一个mdf文件和两个log文件。
AdventureWorksLT2008_Data.mdf
AdventureWorksLT2008_Log.ldf
AdventureWorksLT2008_Data_log.ldf(这个文件是新增的,改用mdf文件添加后,原来的log文件不再起作用,感觉是换了新的连接方式和新的存储机制。)

邀月总结:
这种连接方式可能还是传统的连接方式来得可靠,可能涉及全文检索,性能优化等诸多问题。以后再慢慢研究

邀月注:本文版权由邀月 和CSDN共同所有,转载请注明出处。
助人等于自助! 3w@live.cn


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics