When using a prepared statement in the Pomelo MySQL C# Connector, the syntax for adding parameters is as such:
String sqlCommand = "select * from db where username=@param1"
MySqlCommand command = connection.CreateCommand();
command.Parameters.AddWithValue("@param1", "Ben");
The issue I'm having is that because the syntax for using User-Defined Variables in MySQL is:
String sqlCommand = "SET @userVar1 := 18; select * from db where username=@param1 AND age > @userVar1"
Note that the use of the user variable here is simply to demonstrate syntax.The real example that I'm using this in requires the use of both prepared statements and user variables. However, because of this syntax conflict I'm getting:
Fatal error encountered during command execution. ---> Pomelo.Data.MySql.MySqlException: Parameter '@userVar1' must be defined
Has anyone encountered a similar issue?