String was not recognized as a valid DateTime

  • chris K Ellsworth

    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("",
                    "timeclock","sheikjoe","dansdata").AsString );

    MySQLCommand my_mysql_command;
    MySQLDataReader my_mysql_datareader;

    string my_sql_query = "SELECT fullname,inout,timestamp,notes FROM info";

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


    • chris K Ellsworth

      ok i figured out where in the mysqldrivercs file that it has the problem:
      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)


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks