2/05/2013

VB 2008 : Problem Unable to convert MySQL date/time

Unable to convert MySQL date/time value to System.DateTime
Problem
You receive the following message when running your application:
Unable to get records. Unable to convert MySQL data/time value to System.DateTime.
In certain versions of MySQL, date values are saved as 0000-00-00 instead of a NULL which causes an error when running your application.

Problem
Step 1: Make sure that date columns in the MySQL database either contains all valid values or contain NULL.
Step 2: Add the “Allow Zero Datetime=true” attribute to your database connection string in your application’s Web.config file, e.g.:


  1. <add name="Databasesalika1"
  2.      connectionString="Data Source=qaxp-net;Port=3306;
  3.      Database=salika;
  4.      User Id=ironspeed1;Password=ironspeed1;
  5.      Allow Zero Datetime=true"
  6.      providerName="MySql.Data.MySqlClient"
  7. />

No comments:

Post a Comment