I'm building a parameterized MySql query in C#. I'm having a problem with the endDate parameter.
cmd.Parameters.Add("@enddate", MySqlDbType.Date).Value = endDate.Date;
endDate is DateTime variable. The date column in the table is Date. When the code is running against MySql 5.7 all is well. Running against mySql 8 I get an "Incorrect DATE value: ''" error. I have tried many variants of handling the date. My last effort was this
string strEndDate = endDate.ToString("yyyy-MM-dd");
cmd.Parameters.Add("@enddate", MySqlDbType.Date).Value = DateTime.ParseExact(strEndDate, "yyyy-MM-dd", CultureInfo.InvariantCulture);
Every effort ends in the "Incorrect DATE value: ''" error. From this message it seems the parameter is seen as ''.
How do I get this thing to work with MySql v8?