title: Passing parameters to IdbCommand for mySQL database
body: <p>I am trying to do something relatively simple using IdbCommand to execute an insert query.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>using (IDbConnection conn = DbHelper.GetConnection(DbConnString))
          using (IDbCommand com = conn.CreateCommand())
          {
              com.CommandType = CommandType.Text;
              com.CommandText =
                  String.Format(
                      "INSERT INTO {0} (`Date`, User, Type, `Comment`) VALUES (@Date, @User, @Type, @Comment);",
                      TableName);
              conn.Open();
  
              var parameterDate = com.CreateParameter();
              parameterDate.ParameterName = "@Date";
              parameterDate.Value = entry.Date;
              parameterDate.DbType = DbType.DateTime;
              com.Parameters.Add(parameterDate);
  
              var parameterUser = com.CreateParameter();
              parameterUser.ParameterName = "@User";
              parameterUser.Value = entry.User;
              parameterUser.DbType = DbType.String;
              com.Parameters.Add(parameterUser);
  
              var parameterLogType = com.CreateParameter();
              parameterLogType.ParameterName = "@Type";
              parameterLogType.Value = entry.Type;
              parameterLogType.DbType = DbType.Int32;
              com.Parameters.Add(parameterLogType);
  
              var parameterComment = com.CreateParameter();
              parameterComment.ParameterName = "@Comment";
              parameterComment.Value = entry.Comment;
              parameterComment.DbType = DbType.String;
              com.Parameters.Add(parameterComment);
  
              com.ExecuteNonQuery();
  </code></pre>
  
  <p>But I keep getting a MySqlException with the message "Column 'Date' cannot be null". </p>
  
  <p>All my selects work fine, it's just this insert that has a problem and I can't see an obvious problem with it.</p>
  
  <p>The parameter is populated with a valid DateTime during runtime. 
  I thought it might be related to the fact that Date is a reserved word and needs backquotes, but that's what online tutorials recommend.</p>
  
  <p>Any ideas?</p>