开发者

Insert Date to MySql using c#

I have Date field in my mysql table. I want to insert the date through my Date picker control of windows forms c#. How ?

when i tried using below, i am getting error.

Code :

DB.Insert_Orders(Convert.ToInt32(txtA.Text), Convert.ToInt32(txtB.Text), Convert.ToInt32(txtC.Text), DTP_date.Value.ToString("yyyy/MM/dd"));


Error :
{MySql.Data.MySqlClient.MySqlException: Incorrect datetime value: '15' for column 'Date开发者_如何学编程' at row 


Try

DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

Or

DateTime.Now.ToString("yyyyMMddHHmmss");


You need to convert the value of datetime picker in to type DateTime. Then pass the value.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜