using System; using System.Collections.Generic; using System.Text; using System.Data; using MySql.Data; using MySql.Data.MySqlClient; using MySql.Data.Types; namespace CABug19261test { class Program { static void Main(string[] args) { Console.WriteLine("Connecting to Mysql DB"); String connectionString = "Server=localhost;port=3306;Database=test;uid=root;pwd=;";//Connection Timeout=5;Pooling=false;Max Pool Size=80;Min Pool Size=20; MySqlConnection oConnection = new MySqlConnection(); try { //Create the connection to the db server oConnection.ConnectionString = connectionString; oConnection.Open(); //PREP CASE //Create the db command IDbCommand oCommand = null; string sRequest = "insert into `blacklist`(`SubscriberID`,`Phone`,`ContactID`,`AdminJunk`) values (?SubscriberID,?Phone,?ContactID, ?AdminJunk);"; MySqlParameter oParameterSubscriberID = new MySqlParameter(); oParameterSubscriberID.ParameterName = "?SubscriberID"; oParameterSubscriberID.DbType = DbType.Int32; oParameterSubscriberID.Value = 1; MySqlParameter oParameterPhone = new MySqlParameter(); oParameterPhone.ParameterName = "?Phone"; oParameterPhone.DbType = DbType.String; oParameterPhone.Value = "123456"; MySqlParameter oParameterContactID = new MySqlParameter(); oParameterContactID.ParameterName = "?ContactID"; oParameterContactID.DbType = DbType.Int32; oParameterContactID.Value = 19261; MySqlParameter oParameterAdminJunk = new MySqlParameter(); oParameterAdminJunk.ParameterName = "?AdminJunk"; oParameterAdminJunk.DbType = DbType.Boolean; oParameterAdminJunk.Value = true; IDbCommand DataAssemblyCommandClass = null; DataAssemblyCommandClass = oConnection.CreateCommand(); DataAssemblyCommandClass.CommandText = sRequest; oCommand = (IDbCommand)DataAssemblyCommandClass; //EXECUTE //1st case, ok Console.WriteLine("\nTesting Bug 19261, same order as in select, no NULL values"); oCommand.CommandText = sRequest; oCommand.Parameters.Add(oParameterSubscriberID); oCommand.Parameters.Add(oParameterPhone); oCommand.Parameters.Add(oParameterContactID); oCommand.Parameters.Add(oParameterAdminJunk); oCommand.Prepare(); oCommand.ExecuteNonQuery(); Console.WriteLine("Testing Bug 19261, same order as in select, no NULL values - OK"); //2nd case, exception Console.WriteLine("\nTesting Bug 19261, different order than in select"); oCommand.Parameters.Clear(); oCommand.Parameters.Add(oParameterSubscriberID); oCommand.Parameters.Add(oParameterPhone); oCommand.Parameters.Add(oParameterAdminJunk); oCommand.Parameters.Add(oParameterContactID); oCommand.Prepare(); oCommand.ExecuteNonQuery(); Console.WriteLine("Testing Bug 19261, different order than in select - OK"); //3rd case, exception Console.WriteLine("\nTesting Bug 19261, same order as in select, NULL values"); oCommand.Parameters.Clear(); oParameterPhone.Value = System.DBNull.Value; oParameterContactID.Value = System.DBNull.Value; oCommand.Parameters.Add(oParameterSubscriberID); oCommand.Parameters.Add(oParameterPhone); oCommand.Parameters.Add(oParameterContactID); oCommand.Parameters.Add(oParameterAdminJunk); oCommand.Prepare(); oCommand.ExecuteNonQuery(); Console.WriteLine("Testing Bug 19261, same order as in select, NULL values - OK"); //END test case Console.WriteLine("\nPress any key to exit"); Console.ReadKey(); oConnection.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadKey(); oConnection.Close(); } } } }