1

我编写了一个 C# 桌面(winforms)应用程序,它本质上是我编写的 Web 应用程序的克隆。Web 应用程序能够很好地与数据库来回通信。但是,当我安装桌面应用程序时,出现以下错误:

与 SQL Server 建立连接时发生与网络相关或特定于实例的错误

我在桌面应用程序中使用与在 Web 应用程序中使用的完全相同的连接字符串,如下所示:

"Data Source=tcp:s08.winhost.com;Initial Catalog=THEDATABASE;
            User ID=USERNAME;Password=******;Integrated Security=False;"

我无法使用 SQL Server 配置管理器,因为我的数据库托管在 Winhost.com 上。但是,他们已经向我明确表示,正确的端口已打开,命名管道已打开,并且 SQL 浏览器已正确配置。如果有人遇到过类似的问题,请告诉我您为解决此问题所做的工作。我还在下面包含了整个错误。

谢谢

************** Exception Text **************
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: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) ---> System.ComponentModel.Win32Exception (0x80004005): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

4

2 回答 2

1

删除 TCP 协议名称和端口号并尝试使用完整的托管网站地址..类似这样

  Data Source=www.winhost.com;Initial Catalog=THEDATABASE;
             User ID=USERNAME;Password=**;Integrated Security=False;
于 2012-10-19T20:03:25.727 回答
0

最终我发现问题出在代理服务器上。该应用程序正在被设置了代理服务器的公司使用,并且由于此端口 1433 被阻止。我最终通过创建网络服务解决了这个问题。

于 2012-10-29T01:26:41.037 回答