2011-07-23 102 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服务已在您的计算机上启动。