I am tryng to use Parameterised queries with MySQL. The theory seems pretty straight forward, you create a new instance of the MySqlCommand class like so:
MySqlCommand command = new MySqlCommand();
Set the CommandText property of this object to a MySQL query with placeholders like so:
command.CommandText = "INSERT INTO `myTable` (`myField`) VALUES('@bar');
Use the AddWithValue method to replace my placeholder text with an actual value:
command.Parameters.AddWithValue("@bar", "HelloWorld");
This is how I thought it worked, but in reality the word “@bar” ends up being appended, as opposed to “HelloWorld”.
What am I doing wrong?
try without wrapping in single quote