0

I have added a Datagridview and I clicked Preview data to view Data called from the Mysql database which contains Date and Time and some other information. now i get this in return :

unable to convert MYSQL date/time to System.Date.Time datagridview

Fill,GetData() could not be previewed

Why do i keep getting this as an exception and what must i do

Markaz
  • 15
  • 5
  • This is a MySQL "feature" everyone would consider a bug - Zero dates. MySQL allows the invalid `0000-00-00` value as a "missing" date along with the normal `NULL`. You'll have to either *prevent* the storeage of such values in the database, or set the appropriate connection settings to allow and load "Zero" dates as `0001-01-01` – Panagiotis Kanavos Oct 16 '17 at 10:24
  • @PanagiotisKanavos this is C# – Markaz Oct 16 '17 at 10:26
  • This is a C#/MySQL question. And already answered. Either prevent those values, or convert them to `0001-01-01` with the appropriate connection string setting. I'd prefer to *prevent* them – Panagiotis Kanavos Oct 16 '17 at 10:26
  • Thanks, it was allowing zero in connection string i did this : server=localhost;User Id=root;password=;Persist Security Info=True;database=*******;Convert Zero Datetime=True and it went away – Markaz Oct 16 '17 at 10:30
  • Remember then, that the 0 value gets convertet to a *different one*, `0001-01-01`. If you save the record, the saved value will change. – Panagiotis Kanavos Oct 16 '17 at 10:32

0 Answers0