最近用.net程序连接SqlServer时,总是报“The requested database LocalMySqlServer does not have provider name set in the connection string.”,
经检查,程序配置文件内连接串格式完全正确。也未发现有"LocalMySqlServer"字样的连接串。
分析.net 找配置文件的顺序,肯定是优先找machine.config内的配置了(注:此文件的位置C:\WINNT\Microsoft.NET\Framework内对应版本的 Config子目录内)。
于是找开machine.config,果然发现:
<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="" />
</connectionStrings>
对上述配置项进行注释后,程序启动正常
原文:https://www.cnblogs.com/todayhero/p/11229847.html