SqlConnection错误命名管道提供程序 [英] SqlConnection error Named Pipes Provider

查看:115
本文介绍了SqlConnection错误命名管道提供程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一些背景:

我有一个Windows .NET应用程序,整个北美地区大约40位现场员工正在使用.该程序允许用户在现场(远离Internet访问)输入数据,然后在晚上同步到我们的Sql Server 2005数据库.几天前,我的两个用户报告说他们执行尝试连接到我们的服务器数据库(使用.NET的SqlConnection类)的操作时收到以下错误.

I have a Windows .NET application that is in use by approximately 40 field employees across North America. This program allows the users to enter data while in the field (away form internet access) and then synchronizes to our Sql Server 2005 database at night. A couple days ago, two of my users reported getting the following error when they performed an action that would attempt to connect to our server database (which uses .NET's SqlConnection class).

System.Data.SqlClient.SqlException:A 与网络有关或与实例有关 建立A时发生错误 与SQL Server的连接.服务器 找不到或无法访问. 验证实例名称为 正确并且该SQL Server是 配置为允许远程 连接. (提供者:命名管道 提供程序,错误:40-无法打开 连接到SQL Server)

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)

我们的现场员工通常使用酒店的Wi-Fi连接进行操作,起初我以为他们俩在同一天碰巧都进入了不合作"网络.第二天,转移到不同的酒店后,其中一个用户的问题消失了,而另一个用户则继续存在.

Our field employees are typically operating on a hotel Wi-Fi connection, and at first I thought that they both coincidentally got on an "uncooperative" network the same day. The following day, having moved to different hotels, the problem went away for one of these users, but continued for the other.

除了提供错误消息外,此背景的目的是指出

Besides providing the error message, the purpose of this background is to point out that

  • 这是使用此软件一年以来第一次出现此问题,并且
  • 我们的大多数用户在使用相同软件连接到我们的服务器数据库时都没有问题.

这让我犹豫了一下,问题出在服务器上(我已经阅读过有关此错误的大多数论坛和博客都提供了确保SQL Server配置正确的步骤).

This makes me hesitate to think that the issue is at the server (most forums and blogs I've read on this error provide steps to ensure the SQL Server is configured properly).

忽略错误消息的 Named Pipes Provider 部分,我猜想也许是该用户的计算机或网络导致其尝试通过管道而不是TCP进行连接,所以我确实尝试将服务器配置为允许TCP/IP和命名管道都用于远程连接,以前它仅设置为TCP/IP.更改此设置后,此用户仍然发生错误.

Noticing the Named Pipes Provider portion of the error message, I guessed that maybe this user's computer or network was causing it to attempt connection via pipes rather than TCP, so I did try configuring the server to allow BOTH TCP/IP and Named Pipes for remote connections, where it was previously set to TCP/IP only. The error continued for this one user after changing this setting.

因此,现在我要集思广益,讨论该用户的计算机/软件/Internet连接可能有什么特殊之处,这会阻止该用户连接到我们的SQL Server.

So now I'm left to brainstorm about what could be special about this one user's computer / software / internet connection that would hinder it from being able to connect to our SQL Server.

我们的连接字符串确实使用了服务器的URL(而不是IP地址),我想知道他的笔记本电脑是否无法通过该地址找到它.但是,他可以访问使用相同URL托管的网站,所以我想问题出在其他地方.

Our connection string does use our server's URL (not IP address), and I wondered if his laptop was having problems finding it by that address. However, he was able to access a website hosted from the same URL, so I guess the problem is somewhere else.

任何想法都将不胜感激.谢谢!

Any ideas would be greatly appreciated. Thanks!

推荐答案

您可能已经很长时间解决了该问题,或者已经继续进行,但是对于那些在连接到计算机时遇到错误40/命名管道问题的情况SQL Server实例,以下简单的解决方案对我们有用:

You've probably long since solved this problem by now or moved on, but for those having similar problems with the Error 40/named pipes issue when connecting to a SQL server instance, the following simple solution worked for us:

通过在连接字符串中添加前缀,可以强制客户端程序使用TCP(或命名管道或其他可用方法).

You can force your client program to use TCP (or named pipes, or other available methods) by adding a prefix in your connection string.

对于.NET SQLConnection示例,请在SQLConnection的连接字符串中指定,如下所示:

For the .NET SQLConnection example, specify in the SQLConnection's connection string like so:

Server=tcp:192.168.0.1;Integrated Security=SSPI; database=sampledb

查看全文

相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆