tags:

views:

61

answers:

2

i am developing window application using visual studio and c# i want to insert date in Mysql database table which having datatype date

using datetimepicker control of visual studio

i wrote insertquery like this (insert into table name values('"+ datetimepicker.value + "')

it give me following error

ERROR [HY000] [MySQL][ODBC 3.51 Driver][mysqld-5.1.47-community]Incorrect datetime value: '01-06-2010 00:00:00' for column 'Date' at row 1

can any one resolve this problem

+2  A: 

Use parameterized queries instead. Your code is subject to SQL injection attacks.

RedFilter
A: 

the Mysql DATE() datatype have the Format: YYYY-MM-DD.

you must trim out the time part of the .NET date type OR you can use the Mysql DateTime DataType.

vaitrafra