Bug #100159 SQL with DateTime parameter returns String value
Submitted: 8 Jul 2020 15:11 Modified: 26 Aug 2020 14:18
Reporter: Andrey Belykh Email Updates:
Status: Closed Impact on me:
Category:Connector / NET Severity:S2 (Serious)
Version:8.0.20 OS:Microsoft Windows
Assigned to: CPU Architecture:x86

[8 Jul 2020 15:11] Andrey Belykh
SQL with DateTime parameter returns String value

How to repeat:
using System;
using System.Data;
using System.Data.Common;
using System.Diagnostics;
using MySql.Data.MySqlClient;
namespace ConsoleApp44
    class Program
        static void Main(string[] args)
            string connectionString = "Data Source=DBTEST;Database=sakila;SslMode=None;User ID=root;Password=Dundas123;";
            using (MySqlConnection connection = new MySqlConnection(connectionString))
                string sql = "SELECT ?p0 as datevalue";
                using (MySqlCommand command = new MySqlCommand(sql, connection))
                    command.Parameters.AddWithValue("?p0", DateTime.UtcNow);
                    using (MySqlDataReader reader = command.ExecuteReader())
                        using (DataTable schema = reader.GetSchemaTable())
                            MySqlDbType providerType = (MySqlDbType)schema.Rows[0].Field<int>(SchemaTableColumn.ProviderType);
[8 Jul 2020 20:37] Andrey Belykh
Current (incorrect) output: VarChar

Expected output: DateTime
[9 Jul 2020 7:05] MySQL Verification Team
Hello Andrey,

Thank you for the report and test case.

[24 Jul 2020 16:46] Christine Cole
Posted by developer:
Fixed as of the upcoming MySQL Connector/NET 8.0.22 release, and here's the proposed changelog entry from the documentation team:

A valid query parameter of type DateTime was misinterpreted as a string

Thank you for the bug report.
[26 Aug 2020 14:18] Andrey Belykh
Whens do you plan to release MySQL Connector/NET 8.0.22? Thanks.