I am using parametrized statements for INSERT, involving a couple columns of type TinyInt. I noticed that if I have a TinyInt parameter in a prepared statement, consequent parameters' values are not sent correctly. Here is an example:
Simple schema:
Code: Select all
CREATE TABLE IF NOT EXISTS `tiny_int_test_case` (
`key` int(11) NOT NULL AUTO_INCREMENT,
`value` tinyint(4) NOT NULL,
PRIMARY KEY (`key`)
) ENGINE=InnoDB AUTO_INCREMENT=456;
Code: Select all
string UpdateCommandText = "UPDATE `tiny_int_test_case` SET `value`=? WHERE `key`=?;";
var updateCmd = new MySqlCommand( UpdateCommandText, connection );
updateCmd.Parameters.Add( "value", MySqlType.TinyInt );
updateCmd.Parameters.Add( "key", MySqlType.Int );
updateCmd.Prepare();
Code: Select all
updateCmd.Parameters[0].Value = (byte)123;
updateCmd.Parameters[1].Value = 456;
updateCmd.ExecuteNonQuery();
Code: Select all
UPDATE `tiny_int_test_case` SET `value`=123 WHERE `key`=456
Code: Select all
UPDATE `tiny_int_test_case` SET `value`=123 WHERE `key`=116736
Please let me know if this is something I can fix, or if it's a bug.