title: How to insert DateTime object using Odbc?
body: <p>Simple MySQL table containing a single column of type <code>timestamp</code>.</p>
  
  <pre><code>OdbcCommand command = new OdbcCommand("INSERT INTO `mytable` VALUES (?)", DbConnection);
  command.Parameters.Add("", OdbcType.Timestamp).Value = DateTime.Now;
  OdbcDataReader reader = command.ExecuteReader();
  </code></pre>
  
  <blockquote>
    <p>InvalidCastException: Could not convert parameter from DateTime to
    Byte[]</p>
  </blockquote>
  
  <p>Error has been translated, but you get the point. How do I insert it correctly?</p>
  
  <p>FYI: I also tried to convert the formatted DateTime string (<code>.ToString(""yyyy-MM-dd HH:mm:ss"")</code>) to a byte array using the function found <a href="https://stackoverflow.com/a/10380166/941764">here</a>. It inserts fine but it results is <code>0000-00-00 00:00:00</code>.</p>