开发者

cant insert date to mysql DB from c#

I'm using c sharp and mysql. when i'm trying to insert a date from DateTime type to date colum开发者_StackOverflow社区n in DB all i get is 0000-00-00

i'm parsing my DateTime like this : sessionDate.ToShortDateString()

but getting empty date ...

any help please


MySql uses date in yyyy-MM-dd format,So U can overide the toString() method Of DateTime.Now property.

YourDate= DateTime.Now.ToString("yyyy-MM-dd");


Try this to format your date time to a string value that is acceptable to MySQL

String.Format("{0:yyyy-MM-dd}", sessionDate);

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜