2010-01-29 163 views
2

我無法連接到SQL Server數據庫。無法連接到SQL Server數據庫

我試圖建立會員與使用MSDN教程我的網站的角色。它曾經只在我的機器上本地工作,但是在遵循不同論壇上提供的建議以及在stackoverflow上,情況惡化了,現在我甚至無法連接到SQL Server數據庫。

當我運行aspnet.regsql.exe工具,我得到了以下錯誤消息:

"Setup failed. 

Exception: 
Unable to connect to SQL Server database. 

---------------------------------------- 
Details of failure 
---------------------------------------- 

System.Web.HttpException: Unable to connect to SQL Server database. ---> System.Data.SqlClient.SqlException: 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) 
    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) 
    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) 
    at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject) 
    at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) 
    at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) 
    at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) 
    at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) 
    at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) 
    at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) 
    at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) 
    at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) 
    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.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString) 
    --- End of inner exception stack trace --- 
    at System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString) 
    at System.Web.Management.SqlServices.SetupApplicationServices(String server, String user, String password, Boolean trusted, String connectionString, String database, String dbFileName, SqlFeatures features, Boolean install) 
    at System.Web.Management.SqlServices.Install(String database, SqlFeatures features, String connectionString) 
    at System.Web.Management.ConfirmPanel.Execute()" 

另外,我無法使用ASP.NET網站Adimistration工具。當我點擊安全標籤上我收到以下錯誤:

"There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store. 

The following message may help in diagnosing the problem: Unable to connect to SQL Server database." 

所以,我點擊「選擇數據存儲」按鈕的指示,這讓我選擇一個供應商。該提供者名爲'AspNetSqlProvider',它旁邊有一個測試鏈接。我單擊測試並收到以下錯誤信息:

"Could not establish a connection to the database. 
If you have not yet created the SQL Server database, exit the Web Site Administration tool, use the aspnet_regsql command-line utility to create and configure the database, and then return to this tool to set the provider." 

此頁上唯一的其他選項是單擊「返回」。

有人可以幫我解決這個問題嗎?現在已經過了一個多星期了,我已經搜索了很高的和低的答案,並且給了很多沒有幫助的帖子的鏈接。我會很感激任何幫助。

我試圖運行配置工具的表面和啓用管道,本地/遠程連接,雖然這並沒有區別的。

我人甚至走得更遠,完全卸載的Visual Web Developer和SQL Server 2005和2008,並刪除留下這些應用背後的所有痕跡,然後重新下載所有這些,再重新安裝它們。

到目前爲止沒有運氣。

請幫 感謝

巴爾

編輯

因爲我已經試過禁用我的防火牆更改端口,沒有運氣。

SOLUTION

是的,這可能是有點激烈。我認爲這個解決方案應該只是在所有其他方式都失敗時的最後手段。

我設法解決什麼是錯的通過卸載SQL Server 2005和2008年再註冊的,下載SQL Server Express的2008年版(與管理工具),並安裝它們。安裝完成

後,我關閉Visual Web Developer中,再次打開它,打開ASP.NET網站管理工具後,點擊安全標籤上,因爲一切纔剛剛「工作」 ...

回答

1

你能本地連接使用sqlcmd? 您可以使用來自遠程機器的sqlcmd進行連接嗎?

您是否使用SQL用戶名/密碼或受信任的Windows身份驗證?如果是後者,請以不同的用戶身份運行CommandPrompt/Powershell並查看是否可以連接。

我的猜測是你沒有添加登錄到SQL,並且你正在運行aspnet.regsql.exe而沒有升級權限。如果它從以管理員身份運行的命令提示符成功運行,那麼這是一個有用的標誌。

有一些潛在的問題,但升級的權限是我目前經常看到的。最好創建一個專用帳戶,對SQL實例進行適當的訪問權限,然後運行命令提示符作爲該帳戶(shift-right-click以獲取舊的「運行方式」選項)。

+0

我無法在本地或遠程連接到sqlcmd。我正在使用Windows身份驗證。我不能改變這個選項,因爲它不能連接等我用管理員證明運行aspnet_regsql。我只點擊右鍵並選擇以管理員身份運行(即使我已經以管理員身份運行),然後按照這些步驟獲取完全相同的錯誤消息。 – 2010-01-29 02:13:40

+0

您可以使用SQL Server Management Studio(以管理員身份運行)進行連接嗎?如果是這樣,請檢查實例名稱是 - 是YourServer還是YourServer \ SomeInstanceName?您需要確保您正確指定。 – 2010-01-29 02:29:13

+0

我現在正在下載SQL Server Management Studio。感謝那。 – 2010-01-29 02:49:17

相關問題