2011-07-23 124 views
2

我設計了asp.net中的web應用程序...我已經發布了一個網站.. 我已經創建虛擬目錄並複製發佈文件.... 和瀏覽網站..在asp.net發佈錯誤

An error has occurred while establishing a connection to the server. When connecting to >SQL Server 2005, this failure may be caused by the fact that under the default settings >SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 >- Could not open a connection to SQL Server) Description: An unhandled exception occurred during the execution of the current web >request. Please review the stack trace for more information about the error and where it >originated in the code.

Exception Details: System.Data.SqlClient.SqlException: An error has occurred while >establishing a connection to the server. When connecting to SQL Server 2005, this >failure may be caused by the fact that under the default settings SQL Server does not >allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a >connection to SQL Server)

Source Error: An unhandled exception was generated during the execution of the current web request. >Information regarding the origin and location of the exception can be identified using >the exception stack trace below.

+0

http://msdn.microsoft.com/en-us/library/dd483479.aspx –

回答

0

您的網站嘗試連接到SQL Server,但連接字符串不匹配。根據您的託管服務器,您必須在您的網站web.config中更改連接字符串。

打開web.config並更改連接字符串設置。

<connectionStrings> 
<add name="DBName" providerName="System.Data.SqlClient" connectionString="uid=; pwd=; database=; server=;Max Pool Size=500"/> 
</connectionStrings> 
+0

我有虛擬目錄中的副本文件...在Web配置文件中的虛擬目錄中的直接文件更改? – Malliga

+0

是的,您需要根據您的託管服務器直接在您的服務器web.config中更改連接字符串信息。 –

+0

通常我的web配置文件 如何更改 – Malliga

0

你需要,如果你正在使用SQL Server 2005.One更多的東西,同時上傳發布的網站bin文件夾

0

添加DLL來更改連接字符串,並提供uid和密碼,這個錯誤可能是由於幾個原因造成的。

1 - 確保您的連接字符串是正確的。您可以檢查here for more info.

2 - 確保你有「本地和遠程連接」屬性被選中與「同時使用
TCP/IP和命名管道」在SQL Server上的選項。

3 - 檢查防火牆以確保它不會阻止請求。

4 - 確保SQL Server和SQL Server Browser服務已在您的計算機上啓動。