ASP.NET网站管理工具:无法连接到SQL Server数据库 [英] ASP.NET Website Administration Tool: Unable to connect to SQL Server database

查看:308
本文介绍了ASP.NET网站管理工具:无法连接到SQL Server数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得身份验证和授权使用我的ASP MVC项目。我已经运行没有任何问题aspnet_regsql.exe的工具,看看我的服务器上的数据库ASPNETDB(使用Management Studio工具)。

在我的web.config我的连接字符串是:


 <&是connectionStrings GT;
 <添加名称=ApplicationServices
     的connectionString =数据源= MYSERVERNAME;集成安全性= SSPI; AttachDBFilename = | DataDirectory目录| ASPNETDB.MDF;用户实例=真
     的providerName =System.Data.SqlClient的/>
 < /&是connectionStrings GT;


我得到的错误是:


  

有与您选择的数据存储问题。这可以通过一个无效的服务器的名称或凭证,或经许可不足引起的。它也可以通过不使能角色管理器功能而引起的。点击下面的按钮被重定向到一个页面,您可以选择一个新的数据存储。


  
  

下面的消息可能会有助于诊断问题:无法连接到SQL Server数据库。


在过去,<一href=\"http://serverfault.com/questions/130434/how-do-i-login-to-sql-server-without-having-to-use-run-as-administrator-when-st\">I有连接到我的数据库因为我需要添加用户的麻烦。我一定要在这里做类似的事情?

修改
更改连接字符串,最终解决了这个问题。
对于我使用VS2010的记录,ASP MVC2,SServer 2008


 &LT;&是connectionStrings GT;
&LT;添加名称=ApplicationServices
     的connectionString =数据源= MYSERVERNAME;集成安全性= TRUE;初始目录= ASPNETDB
     的providerName =System.Data.SqlClient的/&GT;
&LT; /&是connectionStrings GT;



解决方案

您使用的服务器的名称,MYSERVER,仿佛这是一个完整的SQL Server默认实例,不是SQL防爆preSS。我不认为你可以使用AttachDbFilename与一个完全成熟的SQL Server。无论是加\\ SQLEX $ P $干燥综合征(实例名)到您的服务器名称或摆脱AttachDbFileName和使用数据库=NAMEOFDATABASE的

I am trying to get authentication and authorization working with my ASP MVC project. I've run the aspnet_regsql.exe tool without any problem and see the aspnetdb database on my server (using the Management Studio tool).

my connection string in my web.config is:

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

The error I get is:

There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.

The following message may help in diagnosing the problem: Unable to connect to SQL Server database.

In the past, I have had trouble connecting to my database because I've needed to add users. Do I have to do something similar here?

Edit Changing the connection string ultimately solved the problem. For the records I am using VS2010, ASP MVC2, SServer 2008

<connectionStrings>
<add name="ApplicationServices"
     connectionString="data source=MYSERVERNAME;Integrated Security=True;Initial Catalog=aspnetdb"
     providerName="System.Data.SqlClient" />
</connectionStrings>

解决方案

You are using a server name, "MYSERVER" as if this is a full SQl Server Default instance, not Sql Express. I don't think you can use the AttachDbFilename with a full blown sql server. Either add "\SQLEXPRESS" (instance name) to your server name or get rid of the AttachDbFileName and use Database="NAMEOFDATABASE"

这篇关于ASP.NET网站管理工具:无法连接到SQL Server数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆