2010-06-29 66 views
2

我收到以下錯誤,同時連接到我本地的SQL Express:SQL錯誤:驗證實例名稱是否正確,並且SQL Server配置爲允許遠程連接?

An error has occurred. Details of the exception:
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)
Unable to connect to SQL Server database.

我能夠使用Management Studio連接到SQL Server。

我正在使用aspnet_regiis使用以下命令生成會話狀態數據庫。

aspnet_regsql.exe -ssadd -sstype c -d App_SessionState -S [.\SQLEXPRESS] -U [USERiD] -P [Password] 
+0

如果你發佈你正在使用的連接字符串,這將有助於。掩蓋密碼和用戶名。 – 2010-06-29 15:58:12

回答

0

您的數據庫是Windows還是混合模式身份驗證?要使用用戶標識和密碼登錄,服務器需要處於混合模式身份驗證。

要進行檢查,在Management Studio:

1. Right click the server name in the Object Explorer tree on the left and select Properties. 
2. Click Security. 
3. Under Server authentication select SQl Server and Windows Authentication Mode. 
4. Click OK 
5. You need to restart SQL Server, so right click the server name again and select Restart.