不能访问远程数据库的问题error: 40 - Could not open a connection to SQL Server

toxxj 2014-12-23 11:12:25
求助:
我有两个网站,暂时叫网站A和网站B,这两个网站是放在两个不同的域名商的空间,现在的问题是网站A不能连接网站B的数据库了(MS SQL). 两个网站是共用一个数据库(放在网站B的域名空间),这样子方便管理,但自从12月20日开始网站A就不能连接网站B的数据库服务器了。
出现在错误提示如下:

Server Error in '/' Application.

The network path was not found

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.ComponentModel.Win32Exception: The network path was not found

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.

Stack Trace:

[Win32Exception (0x80004005): The network path was not found]

[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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5295887

我能从本地电脑及其它的网站(如网站C,网站D)访问网站B的数据库,但就是网站A不能访问网站B的数据库。
我有联系网站A的域名服务商去解决这个问题,但他们的技术客服回复说不是他们的服务器的问题,然后我又去联系网站B域名服务商,也就是数据库这边的域名商去解决这个问题,同样也是回复说他们这边没有问题。

我有网站A上做过专门的测试,它能访问其它网站的数据库除了网站B的数据库。
同样网站B的数据库能被其它的网站访问,但就是网站A访问不了,提示上面的错误。


大家帮忙看看像这个问题是什么原因引起的,或者之前有没有碰到过这个问题,先谢谢了!


...全文
771 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
範先森 2016-04-30
  • 打赏
  • 举报
回复
如果连接字符串没问题的话,这种情况你可以看看网站B上的数据库端口设置,是否做了安全策略,未将网站A设置访问权限
Jacky0319 2016-04-30
  • 打赏
  • 举报
回复
防火墙设置吧
threenewbee 2014-12-24
  • 打赏
  • 举报
回复
不同计算机应该用tcp/ip访问,而不是named pipe。
qzyf1992 2014-12-24
  • 打赏
  • 举报
回复
http://blog.csdn.net/ericherry/article/details/5672121 网上查了一下貌似修改端口有用你可以试试
宝_爸 2014-12-24
  • 打赏
  • 举报
回复
The network path was not found,这种错误挺奇怪的。。 lz还是贴下连接字符串吧。可以把敏感信息去掉。
toxxj 2014-12-23
  • 打赏
  • 举报
回复
连接字符串是没有问题的,我在本地能测试成功的,而且不能访问也是突然的从20日开始,之前一直是好好的,我未修改任何代码。 另外连接字符串中服务器是使用IP地址的,不是域名。
来自故乡的风 2014-12-23
  • 打赏
  • 举报
回复
从错误信息来看,我猜多半是连接字符串的问题。

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧