String was not recognized as a valid DateTime

Help
2005-04-28
2013-04-09
  • timestamp(14) data type
    ok i have table (see create statement below), and when i am issuing a query against it i am
    getting a System.SystemException of "String was not recognized as a valid DateTime."
    here is some sample data from the table for reference
    'Mike', 'out', '20050321173922',''
    'Mike', 'in', '20050321145423', ''
    'Mike', 'lunch', '20050321145413', ''

    I cannot 4 the life of me figure out why im getting this error except a storge issue or convertion problem.

    --
    CREATE TABLE `info` (
      `fullname` varchar(50) NOT NULL default '',
      `inout` varchar(20) NOT NULL default '',
      `timestamp` timestamp(14) NOT NULL,
      `notes` varchar(250) default NULL,
      KEY `fullname` (`fullname`)
    ) TYPE=MyISAM;
    ---
    MySQLConnection my_sqlconnection=new MySQLConnection( new MySQLConnectionString("192.168.1.109",
                    "timeclock","sheikjoe","dansdata").AsString );

    MySQLCommand my_mysql_command;
    MySQLDataReader my_mysql_datareader;

    string my_sql_query = "SELECT fullname,inout,timestamp,notes FROM info";
             
    my_sqlconnection.Open();

    my_mysql_command = new MySQLCommand(my_sql_query, my_sqlconnection);
    my_mysql_command.CommandType = CommandType.Text;

    my_mysql_datareader=my_mysql_command.ExecuteReaderEx();   
    --

     
    • ok i figured out where in the mysqldrivercs file that it has the problem:
      MySQLDataReader.cs
      line 160
      is how it was:
      dr[(int)i]=DateTime.ParseExact(val,"yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture.DateTimeFormat);

      what i changed it too to fix it:
      dr[(int)i]=DateTime.ParseExact(val,"yyyyMMddHHmmss", CultureInfo.InvariantCulture.DateTimeFormat);

      I dont know if this fix will work for other columns and such but it works for my timestamp(14)