The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Unable to convert MySQL date/time value to System.DateTime

Last post 08-17-2007, 7:17 PM by kwilder. 4 replies.
Sort Posts: Previous Next
  •  08-17-2007, 10:20 AM 4593

    Unable to convert MySQL date/time value to System.DateTime

    I read the "MySql Specific Recommendation" post and it doesn't seem to fix my problem. 

    Any ideas why it can't read my DATETIME fields?

    Thanks,


    King Wilder
    http://www.kingwilder.com
  •  08-17-2007, 11:20 AM 4595 in reply to 4593

    Re: Unable to convert MySQL date/time value to System.DateTime

    It looks like we need to add something to that post. There is something that you add in your MySQL connection string to make DateTime's work.

    It's something like:

    Allow Zero Datetime=True;  (I'm not sure if you want True or False) ?


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  08-17-2007, 1:55 PM 4598 in reply to 4595

    Re: Unable to convert MySQL date/time value to System.DateTime

    That option is briefly mentioned in item 4 of that post. If you leave it out of your connection string, as shown in the sample App.config, it defaults to false, which is correct. The most likely problem is that your tables already contain some zero datetimes stored in them. You will have to root them all out, and replace them with something .NET can handle, such as "0001-01-01".


    David Neal Parsons
    www.entityspaces.net
  •  08-17-2007, 7:06 PM 4605 in reply to 4595

    Re: Unable to convert MySQL date/time value to System.DateTime

    Mike.Griffin:

    It looks like we need to add something to that post. There is something that you add in your MySQL connection string to make DateTime's work.

    It's something like:

    Allow Zero Datetime=True;  (I'm not sure if you want True or False) ?

    I've read conflicting Google posts on this solution.  Even the "MySql Specific Recommendation" says to NOT set it to True.  I don't know what the danger would be if I do.  I  might  give it a try.


    King Wilder
    http://www.kingwilder.com
  •  08-17-2007, 7:17 PM 4606 in reply to 4598

    Re: Unable to convert MySQL date/time value to System.DateTime

    David.Parsons:

    That option is briefly mentioned in item 4 of that post. If you leave it out of your connection string, as shown in the sample App.config, it defaults to false, which is correct. The most likely problem is that your tables already contain some zero datetimes stored in them. You will have to root them all out, and replace them with something .NET can handle, such as "0001-01-01".

    Ok, I added "Allow Zero DateTime=yes" to my connection string and the ASPX Template page loaded, but when I clicked on an item to edit, it gave me this error:

    Specified cast is not valid. 

     

    I did have some zero datetime values and replaced them with '0001-01-01'.  If I'm setting a datetime in .Net code from a different form than the ASPX Templates, is it as simple as this?

     

    Code:
    inq.InquiryDate = DateTime.Now;
     
    King Wilder
    http://www.kingwilder.com
View as RSS news feed in XML