简体   繁体   English

SQL Server通信协议问题

[英]SQL Server communication protocol issue

I am using VSTS 2008 + C# + ADO.Net + SQL Server 2008. My questions about what kinds of communication protocols SQL Server 2008 will be using, more details of my questions, 我正在使用VSTS 2008 + C#+ ADO.Net + SQL Server2008。有关SQL Server 2008将使用哪种通信协议的问题,我的问题的更多详细信息,

  1. If the connection string looks like this, whether Named Pipe or TCP/IP is used? 如果连接字符串如下所示,则使用命名管道还是TCP / IP? Will different communication protocol being used dependent on whether client and SQL Server on the same machine? 是否使用不同的通信协议取决于客户端和SQL Server是否在同一台计算机上?

    Data Source=labtest1;Initial Catalog=CustomerDB;Trusted_Connection=true;Asynchronous 数据源= labtest1;初始目录= CustomerDB; Trusted_Connection = true;异步

  2. In SQL Server Configuration Manager, there are items called "SQL Server Network Configuration" and "SQL Native Client 10.0 Configuration". 在SQL Server配置管理器中,有一些项目称为“ SQL Server网络配置”和“ SQL本机客户端10.0配置”。 I find both of them has configuration options (for communication protocols) of Named Pipe or TCP/IP, what are the differences between "SQL Server Network Configuration" and "SQL Native Client 10.0 Configuration"? 我发现它们都具有命名管道或TCP / IP的配置选项(用于通信协议),“ SQL Server网络配置”和“ SQL Native Client 10.0配置”之间有什么区别?

According to SQL Server 2008 Books Online, this is what happens: 根据SQL Server 2008联机丛书,将发生以下情况:

Connecting Locally on the Server 在服务器上本地连接

When you connect to the Database Engine from a local client (the client application and SQL Server are on the same computer), the connection uses shared memory protocol by default. 当您从本地客户端(客户端应用程序和SQL Server在同一台计算机上)连接到数据库引擎时,默认情况下,该连接使用共享内存协议 SQL Server Native Client accepts any of the following formats to connect locally using the shared memory protocol: SQL Server Native Client接受以下任何格式以使用共享内存协议在本地连接:

  • ""
  • "\\" for a named instance "(local)" “ \\”代表命名实例“(本地)”
  • "(local)\\" for a named instance 命名实例的“(本地)\\”
  • "Localhost" “本地主机”
  • "localhost\\" for a named instance 命名实例的“ localhost \\”
  • A single period "." 单个句号“。”
  • ".\\" for a named instance 命名实例的“。\\”

To connect locally using another protocol (for troubleshooting), do one of the following with the protocol enabled: 要使用其他协议进行本地连接(用于故障排除),请在启用协议的情况下执行以下操作之一:

  • Connect to a client alias that specifies a protocol. 连接到指定协议的客户端别名。 For more information, see "Aliases" in SQL Server Configuration Manager help. 有关更多信息,请参见SQL Server Configuration Manager帮助中的“别名”。
  • Prefix the computer name with the protocol (for example, "np:" or "tcp:"). 在计算机名称前加上协议(例如,“ np:”或“ tcp:”)。
  • Connect to the IP address which results in a TCP/IP connection. 连接到IP地址,这将导致TCP / IP连接。
  • Connect to the fully qualified domain name (FQDN) which results in a TCP/IP connection (for example, "..com" 连接到标准域名(FQDN),该域名将导致TCP / IP连接(例如,“ .. com”

Connecting over the Network 通过网络连接

By default, the default protocol for SQL Server clients is TCP/IP . 默认情况下,SQL Server客户端的默认协议为TCP / IP If the connection cannot be made using TCP/IP, the other enabled protocols are attempted. 如果无法使用TCP / IP建立连接,则尝试其他启用的协议。 A shared memory connection cannot be made over a network. 不能通过网络建立共享内存连接。 Use SQL Server Configuration Manager to enable or disable client protocols, and to change the order in which connection attempts are made. 使用SQL Server配置管理器来启用或禁用客户端协议,并更改进行连接尝试的顺序。

In the Sql Server Configuration Manager, you can define an order for the client protocols - I would assume that's the order the client tries to connect to SQL Server with. 在Sql Server配置管理器中,您可以定义客户端协议的顺序-我假定这是客户端尝试连接到SQL Server的顺序。 Whichever protocol is the first being supported by the server will be used. 将使用服务器首先支持的协议。

AS for the configuration utility: AS用于配置实用程序:

  • SQL Server Network Configuration is all about configuration of network protocols on the server side of things SQL Server网络配置完全是关于在服务器端配置网络协议
  • SQL Native Client Configuration is the client-side configuration SQL Native Client Configuration是客户端配置

If you have a dev box with both on it, you'll see both. 如果您同时拥有两个开发人员框,则会看到两者。 A regular PC connecting to a SQL Server typically doesn't have SQL Server itself installed on it locally, so the server-side settings are meaningless there, obviously. 连接到SQL Server的常规PC通常在本地没有安装SQL Server本身,因此服务器端的设置在那里毫无意义。

Marc

The settings configured in SQL Server Native Client Configuration are used on the computer running the client program. 在运行客户端程序的计算机上使用SQL Server本机客户端配置中配置的设置。 When configured on the computer running SQL Server, they affect only the client programs running on the server. 在运行SQL Server的计算机上进行配置时,它们仅影响服务器上运行的客户端程序。

Microsoft SQL Server clients on a machine communicate with SQL Server servers using the protocols provided in the SQL Server Native Client library file. 计算机上的Microsoft SQL Server客户端使用SQL Server本机客户端库文件中提供的协议与SQL Server服务器进行通信。

Remember that these settings are not used by the Microsoft .NET SqlClient. 请记住,Microsoft .NET SqlClient不使用这些设置。 The protocol order for .NET SqlClient is first TCP, and then named pipes, which cannot be changed. .NET SqlClient的协议顺序是先是TCP,然后是命名管道,不能更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM