SQL Server实例在登录协商期间返回了无效或不受支持的协议版本 [英] The SQL Server instance returned an invalid or unsupported protocol version during login negotiation

查看:459
本文介绍了SQL Server实例在登录协商期间返回了无效或不受支持的协议版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 dotnetcore 1.1 并尝试连接到SQL Server版本 8.00.2055



我在项目内部有2个连接:一个连接到SqlServer 2016,另一个连接到Sql Server 8.00.2055 (Sql Server 2000?)



无法建立第二个连接。这是我遇到的错误:


2017-07-31T11:34:24.8747442 + 02:00 0HL6NUT8S82KF [ERR]用户:-在登录协商期间,SQL Server实例返回了无效或不受支持的协议版本。 (637b11d7)


我正在使用的连接字符串是 Server = MyServerHost;初始目录= MyDatabaseName;用户ID = sa;密码= ********;



知道如何解决此错误吗?


< NET类不支持低于SQL Server 2005的SQL Server版本。或者,它不支持低于TDS 7.2(由TDS引入的版本)的TDS协议版本。 SQL Server 2005)。

  a.tdsVersion =(UInt32)(((((((b [0] <<< 8)| b [1])<< 8)| b [2])<< 8)| b [3]); //字节按Motorola顺序(高字节在前)
UInt32 majorMinor = a.tdsVersion& 0xff00ffff;
UInt32增量=(a.tdsVersion>> 16)& 0xff;

//服务器响应:
// 0x07000000-> Sphinx //注意服务器响应格式对于bwd compat
// // 0x07010000-> Shiloh RTM //通知服务器响应格式对于bwd compat
// // 0x71000001-> Shiloh SP1
// 0x72xx0002-> Yukon RTM
// S.Ashwin

开关提供的信息(majorMinor)
{
case TdsEnums.YUKON_MAJOR<< 24 | TdsEnums.YUKON_RTM_MINOR://育空
if(increment!= TdsEnums.YUKON_INCREMENT){throw SQL.InvalidTDSVersion(); }
_isYukon = true;
休息时间;
case TdsEnums.KATMAI_MAJOR<< 24 | TdsEnums.KATMAI_MINOR:
if(increment!= TdsEnums.KATMAI_INCREMENT){throw SQL.InvalidTDSVersion(); }
_isKatmai = true;
休息时间;
case TdsEnums.DENALI_MAJOR<< 24 | TdsEnums.DENALI_MINOR:
if(increment!= TdsEnums.DENALI_INCREMENT){抛出SQL.InvalidTDSVersion(); }
_isDenali = true;
休息时间;
默认值:
抛出SQL.InvalidTDSVersion();
}

供参考:狮身人面像是7.0,Shiloh是2000,Yukon是2005,Katmai是2008年,德纳利是2012年(这些是代号)。这些名称具有误导性,因为此处验证的版本是TDS协议版本,而不是SQL Server版本。 SQL Server 2012、2014和2016均使用TDS 7.4(每个此参考),这就是为什么除了Denali之外没有其他检查的原因。



这是。NET Framework的引用源

  a.tdsVersion =(UInt32)(((((((((b [0]<< 8)| b [1])<< 8)| b [2 ])<< 8)| b [3]); //字节按Motorola顺序(高字节在前)
UInt32 majorMinor = a.tdsVersion& 0xff00ffff;
UInt32增量=(a.tdsVersion>> 16)& 0xff;

//服务器响应:
// 0x07000000-> Sphinx //注意服务器响应格式对于bwd compat
// // 0x07010000-> Shiloh RTM //通知服务器响应格式对于bwd compat
// // 0x71000001-> Shiloh SP1
// 0x72xx0002->育空地区RTM
//信息由S. Ashwin

开关(majorMinor){
case TdsEnums.SPHINXORSHILOH_MAJOR<< <24 | TdsEnums.DEFAULT_MINOR:// Sphinx& Shiloh RTM
// //注意,狮身人面像和shiloh_rtm只能通过增量
开关(增量)来区分{{b $ b case TdsEnums.SHILOH_INCREMENT:
_isShiloh = true;
休息时间;
case TdsEnums.SPHINX_INCREMENT:
//没有设置标志
break;
默认值:
抛出SQL.InvalidTDSVersion();
}
休息;
case TdsEnums.SHILOHSP1_MAJOR< <24; TdsEnums.SHILOHSP1_MINOR:// Shiloh SP1
if(increment!= TdsEnums.SHILOHSP1_INCREMENT){throw SQL.InvalidTDSVersion(); }
_isShilohSP1 = true;
休息时间;
case TdsEnums.YUKON_MAJOR< <24; TdsEnums.YUKON_RTM_MINOR://育空
if(increment!= TdsEnums.YUKON_INCREMENT){throw SQL.InvalidTDSVersion(); }
_isYukon = true;
休息时间;
case TdsEnums.KATMAI_MAJOR< <24; TdsEnums.KATMAI_MINOR:
if(increment!= TdsEnums.KATMAI_INCREMENT){throw SQL.InvalidTDSVersion(); }
_isKatmai = true;
休息时间;
case TdsEnums.DENALI_MAJOR<< 24 | TdsEnums.DENALI_MINOR:
if(increment!= TdsEnums.DENALI_INCREMENT){throw SQL.InvalidTDSVersion(); }
_isDenali = true;
休息时间;
默认值:
抛出SQL.InvalidTDSVersion();
}

清晰可见对TDS 7.0和7.1的支持。



我无法在网上找到有关不支持低于.NET Core SQL Server 2005的决定的信息,而且最早的提交(自2015年9月起)已经缺乏支持。鉴于SQL Server 2000自2013年以来就不再提供扩展支持,这并非没有道理。



简而言之:要么坚持使用完整的.NET Framework( (但是)已放弃对SQL Server 2000的支持),或升级服务器(强烈建议)。可以想象,您也可以分叉代码以将SQL Server 2000支持反向移植到.NET Core,但这几乎肯定是不值得的。


I am using dotnetcore 1.1 and trying to connect to SQL server version 8.00.2055.

I have 2 connections inside project: one to SqlServer 2016 and another one to Sql Server 8.00.2055 (Sql Server 2000?)

This second connection could not be established. Here is the error I am getting:

2017-07-31T11:34:24.8747442+02:00 0HL6NUT8S82KF [ERR] User : - The SQL Server instance returned an invalid or unsupported protocol version during login negotiation. (637b11d7)

Connection String I am using is Server=MyServerHost; Initial Catalog=MyDatabaseName; User id=sa; Password=********;

Any idea how to fix this error?

解决方案

.NET Core does not support SQL Server versions lower than SQL Server 2005. Or rather, it does not support TDS protocol versions lower than TDS 7.2 (the version introduced by SQL Server 2005). The relevant bit of source:

a.tdsVersion = (UInt32)((((((b[0] << 8) | b[1]) << 8) | b[2]) << 8) | b[3]); // bytes are in motorola order (high byte first)
UInt32 majorMinor = a.tdsVersion & 0xff00ffff;
UInt32 increment = (a.tdsVersion >> 16) & 0xff;

// Server responds:
// 0x07000000 -> Sphinx         // Notice server response format is different for bwd compat
// 0x07010000 -> Shiloh RTM     // Notice server response format is different for bwd compat
// 0x71000001 -> Shiloh SP1
// 0x72xx0002 -> Yukon RTM
// information provided by S. Ashwin

switch (majorMinor)
{
    case TdsEnums.YUKON_MAJOR << 24 | TdsEnums.YUKON_RTM_MINOR:     // Yukon
        if (increment != TdsEnums.YUKON_INCREMENT) { throw SQL.InvalidTDSVersion(); }
        _isYukon = true;
        break;
    case TdsEnums.KATMAI_MAJOR << 24 | TdsEnums.KATMAI_MINOR:
        if (increment != TdsEnums.KATMAI_INCREMENT) { throw SQL.InvalidTDSVersion(); }
        _isKatmai = true;
        break;
    case TdsEnums.DENALI_MAJOR << 24 | TdsEnums.DENALI_MINOR:
        if (increment != TdsEnums.DENALI_INCREMENT) { throw SQL.InvalidTDSVersion(); }
        _isDenali = true;
        break;
    default:
        throw SQL.InvalidTDSVersion();
}

For reference: Sphinx is 7.0, Shiloh is 2000, Yukon is 2005, Katmai is 2008, Denali is 2012 (these are the code names). These names are misleading because the version verified here is the TDS protocol version, not the SQL Server version. SQL Server 2012, 2014 and 2016 all use TDS 7.4 (per this reference), which is why there are no checks beyond Denali.

Here's that same piece of code from the reference source of the .NET Framework:

a.tdsVersion = (UInt32)((((((b[0]<<8)|b[1])<<8)|b[2])<<8)|b[3]); // bytes are in motorola order (high byte first)
UInt32 majorMinor = a.tdsVersion & 0xff00ffff;
UInt32 increment  = (a.tdsVersion >> 16) & 0xff;

// Server responds:
// 0x07000000 -> Sphinx         // Notice server response format is different for bwd compat
// 0x07010000 -> Shiloh RTM     // Notice server response format is different for bwd compat
// 0x71000001 -> Shiloh SP1
// 0x72xx0002 -> Yukon RTM
// information provided by S. Ashwin

switch (majorMinor) {
    case TdsEnums.SPHINXORSHILOH_MAJOR<<24|TdsEnums.DEFAULT_MINOR:    // Sphinx & Shiloh RTM
        // note that sphinx and shiloh_rtm can only be distinguished by the increment
        switch (increment) {
            case TdsEnums.SHILOH_INCREMENT:
                _isShiloh = true;
                break;
            case TdsEnums.SPHINX_INCREMENT:
                // no flag will be set
                break;
            default:
                throw SQL.InvalidTDSVersion();
        }
        break;
    case TdsEnums.SHILOHSP1_MAJOR<<24|TdsEnums.SHILOHSP1_MINOR: // Shiloh SP1
        if (increment != TdsEnums.SHILOHSP1_INCREMENT) { throw SQL.InvalidTDSVersion(); }
        _isShilohSP1 = true;
        break;
    case TdsEnums.YUKON_MAJOR<<24|TdsEnums.YUKON_RTM_MINOR:     // Yukon
        if (increment != TdsEnums.YUKON_INCREMENT) { throw SQL.InvalidTDSVersion(); }
        _isYukon = true;
        break;
    case TdsEnums.KATMAI_MAJOR<<24|TdsEnums.KATMAI_MINOR:
        if (increment != TdsEnums.KATMAI_INCREMENT) { throw SQL.InvalidTDSVersion(); }
        _isKatmai = true;
        break;
    case TdsEnums.DENALI_MAJOR << 24|TdsEnums.DENALI_MINOR:
        if (increment != TdsEnums.DENALI_INCREMENT) { throw SQL.InvalidTDSVersion(); }
        _isDenali = true;
        break;
    default:
        throw SQL.InvalidTDSVersion();
}

Support for TDS 7.0 and 7.1 is clearly visible.

I couldn't find information online on the decision not to support anything lower than SQL Server 2005 in .NET Core and the lack of support is already present in the earliest commit (from September 2015). Given that SQL Server 2000 has been out of extended support since 2013, this is not unreasonable.

In short: either stick to using the full .NET Framework (which has not (yet) dropped support for SQL Server 2000), or upgrade your server (highly advisable). Conceivably, you could also fork the code to backport SQL Server 2000 support to .NET Core, but this is almost certainly not worth the effort.

这篇关于SQL Server实例在登录协商期间返回了无效或不受支持的协议版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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