首页 新闻 赞助 找找看

如何解决:与SQL Server文件(*.mdf)的连接要求安装SQL Server Express

0
悬赏园豆:20 [已解决问题] 解决于 2009-08-21 09:14

按照教程的步骤,我在App_Data文件夹中添加一个数据库文件,但是系统报如下错误信息:


经过才网络中搜索,发现先行者的记录:

Connections to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly. Please verify the installation of the component ...
I've got this error message while trying to add a Database file into a c# website project :-s .
After a bit googling it appears that Visual studio 2005 is trying to connect to a SQLSERVEREXPRESS instance name, and yes this can be change easily, if like me, you have change this name during SQL server express 2005 installation. here we go:

In visual studio 2005, open the Tools menu
click on the "Options" item
Select the "Database Tools" node
Select the "Data Connections" child node

then you have a text box with the following label:
"SQL server Instance Name (blank for default):
"SQLSERVEREXPRESS"

for me it was just a matter of leaving it blank, and then adding a mdf file to the project is just working fine :-D
I've not found the solution anywhere else, I must be stupid... anyway, hope it helps someone.


于是到VS2008中去修改:
(注意,要将左下角的“显示所有设置”的复选框选上,否则看不到“数据连接”项)
将右边的SQLEXPRESS删除,确定。
 
我将SQLEXPRESS使用MSSQLSERVER替换。
但是,问题没有解决。
再搜索,发现如下方法:
You may open your Machine.Config file (the file is in %SystemRoot%\Microsoft.NET\Framework\ver. number\CONFIG ). Try to find the ConnectionString node, modify the setting and make it look like:

<add name="LocalSqlServer" connectionString="data source=.\MSSQLSERVER;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />

备注:红色字体原来为“.\SQLEXPRESS”

尝试下来,还是没有成功!始终报相同的错误信息。
郁闷中ing...... 盼望高手给与指点一二......

问题补充: 补充说明:我不想卸载SQL2005开发版,改装SQL Express版本。那样做既耗时也意义不大,因为还有许多其他的应用需要使用SQL2005开发版的。谢谢!
chunshen的主页 chunshen | 初学一级 | 园豆:119
提问于:2009-08-15 08:08
< >
分享
最佳答案
0

关键是你这个文件是什么方式添加的?

收获园豆:10
邀月 | 高人七级 |园豆:25475 | 2009-08-15 08:58
有2种方式:添加连接和添加现有项。 目前是添加现有项方式出现这样的错误。 见您的博客我的回复。 http://www.cnblogs.com/downmoon/archive/2009/08/20/1550850.html#1621492
chunshen | 园豆:119 (初学一级) | 2009-08-21 09:08
其他回答(2)
0

备注:红色字体原来为“.\SQLEXPRESS” 直接用“.”不可以吗?并且把上面选项中的实例名清除再试试。

我的VS2008和你的不同,没有显示所有配置的复选框。

Options


收获园豆:5
winzheng | 园豆:8797 (大侠五级) | 2009-08-15 21:31
直接用应该是代表本机的名称,不过我安装的SQL有实例名。 真的没有那个“显示所有配置”的复选框:) 挺奇怪的,是不是有速成版的区别啊!
支持(0) 反对(0) chunshen | 园豆:119 (初学一级) | 2009-08-21 09:12
0

如果你是64位的话,那么请参考我的blog上的文章

收获园豆:5
Vincent Yang | 园豆:573 (小虾三级) | 2009-08-19 18:48
我的机器是32位的,不过我搜索过不少这方面的文章,好像有些人即便安装的是Express版本的SQL,也遇到过类似的情况......
支持(0) 反对(0) chunshen | 园豆:119 (初学一级) | 2009-08-21 09:13
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册