[英]Resolve connection issue when calling a WCF service through windows 8 app
[英]Database connection not working when called through wcf service
我的应用程序具有一个DAL层,其中包含一个有效的本地数据库。 我有与数据库交互的测试,它们工作正常。
我也有使用我的DAL提供的功能的wcf服务。 但是,当客户端应用程序调用服务时,不会检索任何数据。 相反,我得到一个例外:
Message =“基础提供程序在打开时失败。”
“ System.Data.Entity”
...。
有一个内部例外:
“无法连接到任何指定的MySQL主机。”
{“未知此类主机”}
“在MySql.Data.MySqlClient.Driver.Open()\\ r \\ n在MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder设置)\\ r \\ n在MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()\\ r \\ n在MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()\\ r \\ n在MySql.Data.MySqlClient.MySqlPool.GetConnection()\\ r \\ n System.Data.EntityClient.EntityConnection.OpenStoreConnectionIfIf上的MySql.Data.MySqlClient.MySqlConnection.Open()\\ r \\ n(Boolean openCondition,DbConnection storeConnectionToOpen,DbConnection originalConnection,String exceptionCode,String tryedOperation,Boolean&closeStoreConnectionOnFailure)”
我验证了我的连接字符串与测试使用的字符串相同。
<add name="loansEntities" connectionString="metadata=res://*/LoansDbModel.csdl|res://*/LoansDbModel.ssdl|res://*/LoansDbModel.msl;provider=MySql.Data.MySqlClient;provider connection string="server=localhost:3306;User Id=root;password=123456;database=dbname;Persist Security Info=True"" providerName="System.Data.EntityClient"/>
该数据库是本地mysql数据库,用户和数据库都存在。 这些服务也是本地的,在IIS Express中运行。
为什么会出现此异常?
这可能是由于多种原因,请检查以下几点:
System.Data.SqlClient
,则将其更改为System.Data.Odbc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.