[Solved] GetDateTime delivers 01.01.0001 00:00:00
Posted: Mon 18 Nov 2013 09:53
Hi Guys,
I am using the current version of dotConnect for MySQL. (8.1.36.0)
In my database I got a datetime column with the value: 0000-00-00 00:00:00
If I query this value from my .Net application I get the value: 01.01.0001 00:00:00
Why?
Best regards,
Philipp
I am using the current version of dotConnect for MySQL. (8.1.36.0)
In my database I got a datetime column with the value: 0000-00-00 00:00:00
If I query this value from my .Net application I get the value: 01.01.0001 00:00:00
Code: Select all
MySqlConnection Connection = new MySqlConnection();
Connection.UserId = "test";
Connection.Password = "test";
Connection.Host = "test";
Connection.Database = "testdb";
Connection.Open();
if (Connection.State == System.Data.ConnectionState.Open)
{
string query = string.Format("select sessions_enddate from sessions where sessions.sessions_id = 48;");
MySqlCommand myCommand = new MySqlCommand(query, Connection);
MySqlDataReader myReader = myCommand.ExecuteReader();
// Always call Read before accessing data.
while (myReader.Read())
{
// returns 01.01.0001 00:00:00
Console.WriteLine(myReader["sessions_enddate"].ToString());
// returns 01.01.0001 00:00:00
DateTime EdnDate = myReader.GetDateTime(myReader.GetOrdinal("sessions_enddate"));
}
// always call Close when done reading.
myReader.Close();
Console.ReadKey();
}
Best regards,
Philipp