Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to connect to SQL Server database

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

"Unable to connect to SQL Server database.".

I'm using 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>
like image 589
user934110 Avatar asked Nov 12 '22 14:11

user934110


1 Answers

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?

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.

like image 96
Bertus Kruger Avatar answered Nov 15 '22 06:11

Bertus Kruger