The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty

时间秒杀一切 提交于 2019-12-23 09:34:24

问题


So yesterday i installed PHP and MySQL on my development machine. Since then i get the following error when trying to run one of my .NET projects:

The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty.

It references this line of the Machine.Config:

<add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

I have searched online, high and low and can confirm that my machine.config HAS the necessary connection string:

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

Interestingly enough, i performed the exact same operation of installing PHP and MySQL on my production server (server 2008) and there is no problem there. My dev machine is Windows 7.

My whole dev machine is broken because of this. How can i repair the machine.config or fix it and resolve this problem? Has anyone experienced this before?

Nugs


回答1:


Maybe there is a web.config somewhere that contains:

<connectionStrings>
    <clear/>
    ...
</connectionStrings>

You might also want to double-check that you're looking at the right machine.config. There are separate machine.configs for each Framework version, and also separate ones for the 32-bit and 64-bit framework.



来源:https://stackoverflow.com/questions/10984507/the-connection-name-localsqlserver-was-not-found-in-the-applications-configura

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!