Time conversion from MySql to System.DateTime

August 2, 2012 § Leave a comment

I face the issue recently on time conversion from MySql to System.DateTime

Because 0000-00-00 00:00:00 is not valid .Net DateTime (minimum value is 00:00:00.0000000, January 1, 0001 in .Net/Java System.Datetime)

If datetime is inserted as ‘ 0000-00-00 00:00:00 ‘ then it throws exception cannot convert MySql DateTime to System.DateTime

To fix this we need to add this to the connection string :

Allow Zero Datetime=true and Convert Zero Datetime=true

Thats it

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

What’s this?

You are currently reading Time conversion from MySql to System.DateTime at Naik Vinay.

meta

%d bloggers like this: