2010-11-18 66 views
0

我有兩個數據庫的Web應用程序;一個用於開發,另一個用於生產。我有一個連接到數據庫並上傳數據的Windows服務。根據我想要定位的數據庫,我在我的服務的app.config中註釋掉了一個連接字符串。如何解決數據庫權限問題?

當然,在我的本地開發計算機上一切正常。我可以使用app.config在數據庫之間切換,並將數據上傳到適當的數據庫。這是一件美麗的事情。真的,這是!

我在兩個新的虛擬服務器上安裝了網絡應用程序。該網站的應用程序工作得很好,並連接到相同的數據庫。

我使用與我的本地開發盒完全相同的app.config安裝了windows服務。我以相同的用戶(我的Windows帳戶)運行Windows服務。但是,該服務僅適用於開發數據庫,​​而不是生產數據庫。讓我重複一遍,同樣的配置文件,但服務可以opnly連接到開發數據庫。

當我切換到使用app.config中的prod數據庫並重新啓動服務時,以下異常會記錄到應用程序的事件日誌中。

The underlying provider failed on Open. 
    System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) 
     at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) 
     at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) 
     at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) 
     at System.Data.SqlClient.SqlConnection.Open() 
     at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) 

我很確定這與權限有關,但我已經用盡瞭解決這個問題的想法。有什麼建議麼?如何確定需要哪些權限使服務與生產數據庫一起工作?

編輯#1 - 直接從app.config,生產數據庫是「數據源= ABCD-SQL \ prod;」這個名字可能有問題嗎?

編輯#2 - 從幾個來源驗證server \ instance約定是正確的。

回答

0

您是否檢查過SQL Server服務是否正在運行?我曾經遇到同樣的問題,並且通過重新啓動服務來解決問題。