C# SqlConnection类中的默认网络协议是什么

C# SqlConnection类中的默认网络协议是什么,c#,asp.net,.net,sql-server,ado.net,C#,Asp.net,.net,Sql Server,Ado.net,在下面的代码片段中,将使用什么网络协议连接到SQL Server?TCP/IP或命名管道或其他 using System; using System.Data.SqlClient; class Program { static void Main() { // // First access the connection string. // ... This may be autogenerated in Visual Studio. //

在下面的代码片段中,将使用什么网络协议连接到SQL Server?TCP/IP或命名管道或其他

using System;
using System.Data.SqlClient;

class Program
{
    static void Main()
    {
    //
    // First access the connection string.
    // ... This may be autogenerated in Visual Studio.
    //
    string connectionString = "Server=SERVER\\INSTANCE;Database=myDataBase;User Id=myUsername;
Password=myPassword;"
    //
    // In a using statement, acquire the SqlConnection as a resource.
    //
    using (SqlConnection con = new SqlConnection(connectionString))
    {
        //
        // Open the SqlConnection.
        //
        con.Open();
        //
        // The following code uses an SqlCommand based on the SqlConnection.
        //
        using (SqlCommand command = new SqlCommand("SELECT TOP 2 * FROM Dogs1", con))
        using (SqlDataReader reader = command.ExecuteReader())
        {
        while (reader.Read())
        {
            Console.WriteLine("{0} {1} {2}",
            reader.GetInt32(0), reader.GetString(1), reader.GetString(2));
        }
        }
    }
    }
}

SQL Server的.NET Framework数据提供程序使用自己的协议 与SQL Server通信。因此,它不支持使用 连接到SQL Server时ODBC数据源名称(DSN)的名称 因为它没有添加ODBC层

还有这个

如果在尝试连接时指定1433以外的端口号 连接到SQL Server实例并使用其他协议 TCP/IP,打开方法失败。指定端口号而不是 1433,在连接中包括“server=machinename,port number” 字符串,并使用TCP/IP协议


根据SQL Server本机客户端:

按照列出的顺序尝试协议,首先尝试使用顶部协议进行连接,然后使用第二个列出的协议进行连接,以此类推

但我们也读到:

Microsoft.NET SqlClient不使用这些设置。.NET SqlClient的协议顺序首先是TCP,然后是命名管道,不能更改


这就是尝试的顺序-首先是TCP,然后是命名管道-因此不会使用“a”协议-这取决于成功的顺序。

所以默认端口号将是1433,协议将是TCP/IP?@RajeshSubramanian-它将尝试首先使用TCP,但可能会退回到命名管道。