From 03a1e0ca1f902f5e8c63dd3dc67be5bd3a2fc409 Mon Sep 17 00:00:00 2001 From: Tsahi Asher Date: Sat, 26 Dec 2020 13:11:32 +0200 Subject: [PATCH] OK, so we can't support parameter discovery for ODBC #39 --- source/Src/Data.Odbc/Data.Odbc.csproj | 15 +++ source/Src/Data.Odbc/OdbcDatabase.cs | 22 ++-- .../Properties/Resources.Designer.cs | 72 ++++++++++ .../Src/Data.Odbc/Properties/Resources.resx | 123 ++++++++++++++++++ 4 files changed, 223 insertions(+), 9 deletions(-) create mode 100644 source/Src/Data.Odbc/Properties/Resources.Designer.cs create mode 100644 source/Src/Data.Odbc/Properties/Resources.resx diff --git a/source/Src/Data.Odbc/Data.Odbc.csproj b/source/Src/Data.Odbc/Data.Odbc.csproj index 2b184a0..a45481c 100644 --- a/source/Src/Data.Odbc/Data.Odbc.csproj +++ b/source/Src/Data.Odbc/Data.Odbc.csproj @@ -42,4 +42,19 @@ + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + diff --git a/source/Src/Data.Odbc/OdbcDatabase.cs b/source/Src/Data.Odbc/OdbcDatabase.cs index 00cb553..b3cd2e8 100644 --- a/source/Src/Data.Odbc/OdbcDatabase.cs +++ b/source/Src/Data.Odbc/OdbcDatabase.cs @@ -42,22 +42,26 @@ public OdbcDatabase(string connectionString) : base(connectionString, OdbcFactor /// the Parameters collection of the specified object. /// /// The to do the discovery. - /// is not an . - /// The underlying ODBC provider does not support returning stored - /// procedure parameter information, the command text is not a valid stored procedure name, or the CommandType - /// specified was not . + /// Always + /// While supports deriving parameters, we don't know + /// which specific database will be used, what are it's parameter discovery capabilities are, + /// and other differences. So we can't support deriving parameters automatically. protected override void DeriveParameters(DbCommand discoveryCommand) { - OdbcCommandBuilder.DeriveParameters((OdbcCommand)discoveryCommand); + throw new NotSupportedException(Properties.Resources.ExceptionParameterDiscoveryNotSupportedOnOdbcDatabase); + //To execute a procedure in ODBC you have to name it as "{ Call procName(?,?,?,?) }" + //in the CommandText. But in this syntax, DeriveParameters doesn't work. + //to derive parameters, you have to give just the procedure name in CommandText, but then + //the ExecuteScalar (for example) doesn't work, complaining a parameter is missing. } /// - /// Determines whether the database provider supports parameter discovery. This depends on the underlying - /// ODBC provider. + /// Determines whether the database provider supports parameter discovery. /// - /// Returns true, but you should consult the documentation for the underlying ODBC provider. + /// Returns false + /// Parameter discovery is not supported for ODBC drivers. /// - public override bool SupportsParemeterDiscovery => true; + public override bool SupportsParemeterDiscovery => false; /// protected override void SetUpRowUpdatedEvent(DbDataAdapter adapter) diff --git a/source/Src/Data.Odbc/Properties/Resources.Designer.cs b/source/Src/Data.Odbc/Properties/Resources.Designer.cs new file mode 100644 index 0000000..e307e20 --- /dev/null +++ b/source/Src/Data.Odbc/Properties/Resources.Designer.cs @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.Practices.EnterpriseLibrary.Data.Odbc.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Practices.EnterpriseLibrary.Data.Odbc.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Parameter discovery is not supported for connections using OdbcDatabase. You must specify the parameters explicitly, or configure the connection to use a type deriving from Database that supports parameter discovery.. + /// + internal static string ExceptionParameterDiscoveryNotSupportedOnOdbcDatabase { + get { + return ResourceManager.GetString("ExceptionParameterDiscoveryNotSupportedOnOdbcDatabase", resourceCulture); + } + } + } +} diff --git a/source/Src/Data.Odbc/Properties/Resources.resx b/source/Src/Data.Odbc/Properties/Resources.resx new file mode 100644 index 0000000..e514e44 --- /dev/null +++ b/source/Src/Data.Odbc/Properties/Resources.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Parameter discovery is not supported for connections using OdbcDatabase. You must specify the parameters explicitly, or configure the connection to use a type deriving from Database that supports parameter discovery. + + \ No newline at end of file