MySqlCommand insertCommand = new MySqlCommand("insert into autotest.simple_types (f_binary, f_varbinary) values (:p1, :p2)", connection);
Encoding encoding = Encoding.Unicode;
byte[] buffer1 = encoding.GetBytes("test1");
byte[] buffer2 = encoding.GetBytes("test2");
insertCommand.Parameters.Add("p1", new MySqlBinaryString(buffer1, encoding));
insertCommand.Parameters.Add("p2", new MySqlBinaryString(buffer2, encoding));
insertCommand.ExecuteNonQuery();
MySqlCommand selectCommand = new MySqlCommand("select f_binary, f_varbinary from autotest.simple_types", connection);
using (MySqlDataReader reader = selectCommand.ExecuteReader())
while (reader.Read())
for (int i = 0; i < reader.FieldCount; ++i) {
MySqlBinaryString value = (MySqlBinaryString)reader.GetProviderSpecificValue(i);
value.Encoding = encoding;
Console.WriteLine(value);
}