Kristian Oye
Kristian Oye

Reputation: 1202

MySqlCommandBuilder.DeriveParameters: Specified cast is not valid

I am using MySql.Data version 8.0.22 on IIS/Windows to try and connect to MariaDB 10.4.12 (Linux). I am trying to use MySqlCommandBuilder.DeriveParameters to fetch parameter information:

        cmd.CommandText = "Mail_SaveEvent";
        cmd.CommandType = CommandType.StoredProcedure;
        MySqlCommandBuilder.DeriveParameters(cmd);

My stored proc/routine has the following parameters:

CREATE PROCEDURE shopmail_test.Mail_SaveEvent(
    IN inEventTypeID int,
    IN inEventDate datetime,
    IN inEventServer int,
    IN inEventTitle varchar(250),
    IN inEventText text,
    IN inEventMerchantID int,
    IN inEventAuditText text,
    IN inEventID int)
  SQL SECURITY INVOKER
  MODIFIES SQL DATA
BEGIN

I thought this might be a collation issue (I am using utf8 with utf8_unicode_ci collation), so I commented out all of the text parameters and even removed most of the logic from the body of the routine but I am still getting the following error:

12/4/2020 11:20 AM][Production  ]:          Specified cast is not valid.
[12/4/2020 11:20 AM][Production  ]:            at MySql.Data.MySqlClient.MySqlCommandBuilder.DeriveParameters(MySqlCommand command)

What's interesting is that if I try and hit this same schema/routine on MariaDB 10.4.17 hosted on a Windows box that the command is populated without any errors.

enter image description here

This is driving me nuts! Has anyone experienced this and found out how to fix it?

Upvotes: 0

Views: 273

Answers (1)

Bradley Grainger
Bradley Grainger

Reputation: 28182

This is probably a bug in MySql.Data (although I don't yet see a relevant report at https://bugs.mysql.com/). You could report it there, and hope that Oracle fixes it in a future version.

Alternatively, switch to MySqlConnector (disclaimer: lead author), which fixes a lot of MySql.Data bugs and has great compatibility with MariaDB.

Upvotes: 1

Related Questions