There is a MySQL query parameter of type BINARY
. Binary values in MySQL can be represented like x'1f7a8e'
. However, when adding a parameter of type MySqlDbType.Binary
to a MySqlCommand
the query is formed with the value represented as _binary '1f7a8e'
which causes the query to not find the row. Below you can see a code example of how the MySQL API is being used.
var baz = "1f7a8e";
var cmd = new MySqlCommand("SELECT foo FROM bar WHERE baz=@baz");
cmd.Parameters.Add("@baz", MySqlDbType.Binary).Value = baz;
// Execute query and read result
What would be the correct way of using a binary value as a parameter?