开发者

in windows service storing datetime in MYSQL database exception

开发者 https://www.devze.com 2023-03-06 21:01 出处:网络
i will be tested the application as windows application then it will be stored the datetime in MySQL data base.when i will be start this application using windows service it will be thrown this except

i will be tested the application as windows application then it will be stored the datetime in MySQL data base.when i will be start this application using windows service it will be thrown this exception.

error [HY000][MySQL][ODBC 3.51 Driver] [MySqlid -6.0.11-alpha-community]incorrect datetime value '5/6/2011 9:00:00 AM' for column column-name at row1"

windows application take the system format & my system format is yyyy-MM-dd hh:mm:ss in windows service which format is used.

 string dt1 = Convert.ToString(DateTime.FromFileTime(e.sts[counter].TimeS开发者_运维问答tamp));
Datetime dt2 = DateTime.ParseExact(dt1,"MM-dd-yyyy hh:mm:ss", CultureInfo.InvariantCulture);

i will be checked the date format of the MYSQL write this code but it will be display the unrecognized string format


If you are recording the time of the windows service event as it happens then I would use the MySQL NOW() function in your query.

0

精彩评论

暂无评论...
验证码 换一张
取 消