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