Hello!
How can I read and write the DateTime value "0000-00-00 00:00:00"?
MySQLDirect converts a MySQL-DateTime to a .NET-DateTime so that this
value is lost. I think it's very important to access this value because it is
a common default-value of MySQL.
Kind regards,
Florian Heinemann
DateTime value 0000-00-00 00:00:00
To read value "0000-00-00 00:00:00" use code below:
Code: Select all
mySqlConnection.Open();
mySqlCommand.CommandText = "select hiredate from Employees";
MySqlDataReader reader = mySqlCommand.ExecuteReader();
reader.Read();
MessageBox.Show(reader.GetString(0));
Hello!Alexey wrote:To read value "0000-00-00 00:00:00" use code below:Code: Select all
mySqlConnection.Open(); mySqlCommand.CommandText = "select hiredate from Employees"; MySqlDataReader reader = mySqlCommand.ExecuteReader(); reader.Read(); MessageBox.Show(reader.GetString(0));
Thank you for your reply. Is there any possibility to get the 0-datetime-value through a DataTable? We use the DataAdapter to fill a DataTable, so we cannot choose the data type of the result data as you do it in your example.
And how can we insert the "0000-00-00 00:00:00" value into a mySQL database using parameters?
Kind regards,
Florian Heinemann
To use MySqlDataAdapter you'll have to adjust your query. E.g.:
To insert the "0000-00-00 00:00:00" value into a mySQL database use the following code:
Code: Select all
select cast(HireDate as char) from Employees
Code: Select all
mySqlConnection.Open();
mySqlCommand.CommandText = "insert into Employees(EmpNo, HireDate) values(6342, :HireDate)";
mySqlCommand.Parameters.Add("HireHate", "00/00/0000 00:00:00");
mySqlCommand.ExecuteNonQuery();