Urgent: Prepared MySqlCommands don't work #1105
-
Hi, So I'm using .NET core 6.0 and MySqlConnector 2.1.1 (Visual Studio 2022) so the latest of each connecting to MySQL 8.0. I can create and run commands successfully WITHOUT using .Prepare() But as soon as I use .Prepare() the command object gets set to a null reference. No exception is thrown other than when trying to subsequently run a method on the command object (which is now null). So the .Prepare() is causing an issue that obviously just wipes the command object, and without reporting an error. I've tried this in a C# managed project and a C++/CLI project using different variations of commands etc... But all do the same thing. MySQL's log reports that the PREPARE command is being sent to MySQL (successfully) but then the actual MySqlCommand gets set to null for some reason. (Note that the same code but using MySql's own MySql.Data package works find with Prepare but unfortunately it doesn't yet support net core 6.0 and obviously isn't as quick.) Could anyone help please? Or provide some sample code using .Prepare() that they know to work please? Thank you in advance. Here's my code: Obviously this is C++/CLI but the exact same issue is present when using pure managed C#. MySqlCommand^ cmdTest = gcnew MySqlCommand(); //I've tried using ? and @ptid as the parameter placeholder. //This line successfully sends a PREPARE statement to MySQL as can be seen in the general log MySqlParameter^ p = cmdTest->Parameters->Add("@ptid", MySqlDbType::Int32); //This line ALWAYS throws a null reference exception whatever variations I use - unless I don't call Prepare() |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Can discuss at #1106; no need to open duplicates. |
Beta Was this translation helpful? Give feedback.
Can discuss at #1106; no need to open duplicates.