2016-03-31 58 views
1

我的應用程序在MVC 4中,使用Entity框架的Sql Anywhere 16 ODBC。我用Visual Studio 2010.需求是多租戶,所以我創建連接字符串動態我的Global.asax和一旦主數據庫已連接,我創建連接字符串基於用戶的數據庫在我的帳戶控制器。Sybase iAnywhere.Data.SQLAnywhere.SAException:DSN數據庫名稱不存在

當我通過visual studio運行時,應用程序運行良好。但是當我在IIS 8.5上發佈此應用程序並在瀏覽器上加載應用程序時,它顯示下面的錯誤。

<ErrorType>System.Data.EntityException: The underlying provider failed 
on Open. ---&gt; iAnywhere.Data.SQLAnywhere.SAException: DSN 'MainDB' 
does not exist at iAnywhere.Data.SQLAnywhere.SAConnection.Open() 
at 
System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean 
openCondition, DbConnection storeConnectionToOpen, DbConnection 
originalConnection, String exceptionCode, String attemptedOperation, 
Boolean&amp; closeStoreConnectionOnFailure) --- End of inner 
exception stack trace --- at 
System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean 
openCondition, DbConnection storeConnectionToOpen, DbConnection 
originalConnection, String exceptionCode, String attemptedOperation, 
Boolean&amp; closeStoreConnectionOnFailure) at 
System.Data.EntityClient.EntityConnection.Open() at 
PDMSReporter.Controllers.AccountController.Login(LoginModel Login) in 
E:\Projects\Triforce_PDM 
Reporter\Latest_PDMSReporter\PDMSReporter\PDMSReporter\Controllers\AccountController.cs:line 
56</ErrorType> 

<ErrorDesc>The underlying provider failed on Open.</ErrorDesc> 

我試了很多來解決這個問題。但沒有找到適當的解決方案。

請幫我解決這個問題或建議後我可以解決它。

回答

0

錯誤消息告訴您:「DSN'MainDB'不存在」。您的連接字符串正在使用客戶端無法找到的DSN。這可能是因爲您正在創建用戶DSN而不是系統DSN - 如果您的客戶端作爲服務運行(即在IIS中),則無法讀取用戶DSN。

如果您使用dbdsn實用程序創建DSN,請確保使用-ws開關而不是-w

+0

哦! k謝謝你的幫助。您能否詳細說明如何製作系統DSN(或任何步驟或博客)。我很抱歉,但我是Sql Anywhere中的新成員,所以我沒有太多想法。 – CrazyDev

+0

你好,我能夠添加系統DSN和它的工作很好,謝謝你的幫助。 – CrazyDev