.net 连接数据库提示"The requested database LocalMySqlServer does not have provider name set in the connection string."

最近用.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>

 对上述配置项进行注释后,程序启动正常

 

posted @ 2019-07-23 09:40  千年海岩  阅读(521)  评论(0编辑  收藏  举报