From 3c45cd751a0dba41d660ad8296a067340b059948 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Fri, 12 Aug 2022 04:32:32 +0300 Subject: [PATCH] Remove 1024 character limit on ODBC connection strings (#73155) Fixes #63630 (cherry picked from commit 8eb5dea6763da89fb9a4fdd4df0942f195716b59) --- src/libraries/System.Data.Odbc/src/Resources/Strings.resx | 3 --- src/libraries/System.Data.Odbc/src/System.Data.Odbc.csproj | 2 ++ .../System.Data.Odbc/src/System/Data/Odbc/Odbc32.cs | 13 +++---------- .../src/System/Data/Odbc/OdbcConnectionString.cs | 8 -------- 4 files changed, 5 insertions(+), 21 deletions(-) diff --git a/src/libraries/System.Data.Odbc/src/Resources/Strings.resx b/src/libraries/System.Data.Odbc/src/Resources/Strings.resx index b6860f2..5332b0d 100644 --- a/src/libraries/System.Data.Odbc/src/Resources/Strings.resx +++ b/src/libraries/System.Data.Odbc/src/Resources/Strings.resx @@ -392,9 +392,6 @@ The ODBC provider did not return results from SQLGETTYPEINFO. - - Connection string exceeds maximum allowed length of {0}. - Unknown SQL type - {0}. diff --git a/src/libraries/System.Data.Odbc/src/System.Data.Odbc.csproj b/src/libraries/System.Data.Odbc/src/System.Data.Odbc.csproj index eff5503..7307a05 100644 --- a/src/libraries/System.Data.Odbc/src/System.Data.Odbc.csproj +++ b/src/libraries/System.Data.Odbc/src/System.Data.Odbc.csproj @@ -5,6 +5,8 @@ $(NoWarn);CA2249;CA1838 enable true + true + 1 Provides a collection of classes used to access an ODBC data source in the managed space Commonly Used Types: diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/Odbc32.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/Odbc32.cs index 6c32692..9f22130 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/Odbc32.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/Odbc32.cs @@ -24,18 +24,17 @@ namespace System.Data.Odbc { return ADP.Argument(SR.GetString(SR.Odbc_UnknownSQLType, sqltype.ToString())); } - internal static Exception ConnectionStringTooLong() - { - return ADP.Argument(SR.GetString(SR.OdbcConnection_ConnectionStringTooLong, ODBC32.MAX_CONNECTION_STRING_LENGTH)); - } + internal static ArgumentException GetSchemaRestrictionRequired() { return ADP.Argument(SR.GetString(SR.ODBC_GetSchemaRestrictionRequired)); } + internal static ArgumentOutOfRangeException NotSupportedEnumerationValue(Type type, int value) { return ADP.ArgumentOutOfRange(SR.GetString(SR.ODBC_NotSupportedEnumerationValue, type.Name, value.ToString(System.Globalization.CultureInfo.InvariantCulture)), type.Name); } + internal static ArgumentOutOfRangeException NotSupportedCommandType(CommandType value) { #if DEBUG @@ -664,12 +663,6 @@ namespace System.Data.Odbc COMPLETE_REQUIRED = 3, } - // todo:move - // internal const. not odbc specific - // - // Connection string max length - internal const int MAX_CONNECTION_STRING_LENGTH = 1024; - // Column set for SQLPrimaryKeys internal enum SQL_PRIMARYKEYS : short { diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnectionString.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnectionString.cs index 74790e0..7efb675 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnectionString.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnectionString.cs @@ -22,14 +22,6 @@ namespace System.Data.Odbc int position = 0; _expandedConnectionString = ExpandDataDirectories(ref filename, ref position); } - if (validate || (null == _expandedConnectionString)) - { - // do not check string length if it was expanded because the final result may be shorter than the original - if ((null != connectionString) && (ODBC32.MAX_CONNECTION_STRING_LENGTH < connectionString.Length)) - { // MDAC 83536 - throw ODBC.ConnectionStringTooLong(); - } - } } } } -- 2.7.4