DevMan DevMan - 1 year ago 84
SQL Question

C# DateTime.Now not writing correct time to MySql database

I have a C# program that communicates with MySql database and I want to write current time to database column defined as TIME. Now, when I run my program the time that has been written is for example 00:00:19 and not for example 19:34:00. Why this happens and how can I solve this?

Thanks in advance


This solved the problem:


Answer Source

this because the format mysql : "yyyy-MM-dd hh:mm:ss"

check the format in you programme or try to insert a String like this "2016-23-08 13:00:00"

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download