Click here to Skip to main content
14,970,669 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
im getting error using dates format on listview subitems

Exception Unhandled
MySql.Data.Types.MySqlConversionException: 'Unable to convert MySQL date/time value to System.DateTime'


What I have tried:

C#
CLSOpen.OPEN("select * from bulksmstable where groupname='" + ComboSheet.Text + "'");

   while (CLSOpen.reader.Read()) 
   {
     ListViewItem li = new ListViewItem(CLSOpen.reader["mobilenumber"].ToString());
     li.SubItems.Add(DateTime.Parse(CLSOpen.reader["datecreated"].ToString()).ToString("MM/dd/yyyy"));
     li.SubItems.Add(DateTime.Parse(CLSOpen.reader["datesend"].ToString()).ToString("MM-dd-yyyy"));
     ListView1.Items.AddRange(new ListViewItem[] { li });
   }
   CLSOpen.CLOSE();



Quote:
Exception Unhandled
MySql.Data.Types.MySqlConversionException: 'Unable to convert MySQL date/time value to System.DateTime'
Posted
Updated 20-May-20 20:03pm
v2
Comments

1 solution

The answer is here: .net - Unable to convert MySQL date/time value to System.DateTime - Stack Overflow[^]

Quote:
This is not a bug but expected behavior. Please check manual under connect options and set "Allow Zero Datetime" to true, as on attached pictures, and the error will go away.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900