无法连接到SQL Server数据库

时间:2022-07-03 17:24:50

When I click the Security tab on the ASP.NET Web Site Administration Tool, I get this error.

当我单击ASP.NET网站管理工具上的安全选项卡时,我收到此错误。

"Unable to connect to SQL Server database.".

“无法连接到SQL Server数据库。”

I'm using Visual Studio 2012

我正在使用Visual Studio 2012

<configuration>
  <connectionStrings>

    <add name="devices" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\devices.mdf;Integrated Security=True"
      providerName="System.Data.SqlClient" />
    <add name="users" connectionString="Data Source=(LocalDB)\v11.0;AttachDbfilename=|DataDirectory|\database.mdf;Integrated Security=True"
      providerName="System.Data.SqlClient"/>

  </connectionStrings>

<system.web>

    <roleManager enabled="true" />
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>
  </system.web>
</configuration>

1 个解决方案

#1


1  

Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\devices.mdf;Integrated Security=True

Looking at your data source. Does (LocalDB)\v11.0 exist and can you connect to the above DB?

查看您的数据源。是否存在(LocalDB)\ v11.0,是否可以连接到上述数据库?

If not that will be the reason....

如果不是那样的原因......

I have found that every time I create a package for my website (For manual deployments), it overwrites my connection string in the package being created with the above data source.

我发现每次为我的网站创建一个包(对于手动部署),它都会覆盖使用上述数据源创建的包中的连接字符串。

This can be a blessing some times preventing your new website from launching. (Especially if its in the wrong environment. :)

这有时会阻止您的新网站启动,这可能是一种祝福。 (特别是如果它在错误的环境中。:)

http://www.connectionstrings.com/ This site is great for helping you creating connection strings for almost any DB.

http://www.connectionstrings.com/此站点非常适合帮助您为几乎任何数据库创建连接字符串。

#1


1  

Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\devices.mdf;Integrated Security=True

Looking at your data source. Does (LocalDB)\v11.0 exist and can you connect to the above DB?

查看您的数据源。是否存在(LocalDB)\ v11.0,是否可以连接到上述数据库?

If not that will be the reason....

如果不是那样的原因......

I have found that every time I create a package for my website (For manual deployments), it overwrites my connection string in the package being created with the above data source.

我发现每次为我的网站创建一个包(对于手动部署),它都会覆盖使用上述数据源创建的包中的连接字符串。

This can be a blessing some times preventing your new website from launching. (Especially if its in the wrong environment. :)

这有时会阻止您的新网站启动,这可能是一种祝福。 (特别是如果它在错误的环境中。:)

http://www.connectionstrings.com/ This site is great for helping you creating connection strings for almost any DB.

http://www.connectionstrings.com/此站点非常适合帮助您为几乎任何数据库创建连接字符串。