title: Only MySqlParameter objects may be stored
body: <p>I followed <a href="https://social.msdn.microsoft.com/forums/vstudio/en-US/a499467f-2be0-4300-abd3-8d67ce5e19f6/sql-with-parameters-using-idbcommand" rel="nofollow">this</a> thread trying to set connection to <code>MySQL</code> and run prepared statements (with minor difference that in the thread they are talking about <code>Postgresql</code>). This is what I've done:</p>
  
  <pre><code>  IDbConnection cnx = new MySqlConnection(connectionString);
    cnx.Open();
    IDbCommand cmd = cnx.CreateCommand();
  
    string sql = "insert into table1 (column2) values ($1)";
  
    cmd.CommandText = sql;
  
    IDbDataParameter param = cmd.CreateParameter();
    param.DbType = DbType.AnsiString;
    param.ParameterName = "1";
    param.Value = "Parameter Value";
  
    cmd.Parameters.Add(param);
    cmd.ExecuteNonQuery();
  </code></pre>
  
  <p>But as a result, I get thie error message:</p>
  
  <blockquote>
    <p>MySql.Data.MySqlClient.MySqlException: Only MySqlParameter objects may be stored
      at MySql.Data.MySqlClient.MySqlParameterCollection.Add (System.Object value) [0x00000] in :0 </p>
  </blockquote>
  
  <p>I should add, that I specifically use <code>IDbConnection</code>, because later I want to reuse this code for other databases and this approach should save me hundreds lines of code.</p>