![](/img/trans.png)
[英]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.