2

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 

2 Answers 2

6

Try

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

Or

DateTime.Now.ToString("yyyyMMddHHmmss");
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.