I need to make a insert
of date with monthCalendar
in C#
in database MySQL
, except that the date format of MySQL
is ( yyyy-MM-dd
) and I've already modified the code:
I changed the input mode (% with%)
cadast.Dataa=Convert.ToDateTime(monthCalendar1.SelectionStart.Date.ToString("yyyy-MM-dd"));
And I modified the class that does yyyy-MM-dd
into the database:
insert
And it has the following error:
Incorrect datetime value error: '30 / 11/2016 00:00:00 'for function str_to_date.
I modified the string inserir = "INSERT INTO consultas (Dataa,Horario, cd_paciente, cro, cd_procedimento) values (str_to_date('" + cadast.Dataa + "','%Y-%m-%d'),'"+cadast.Horario+ "', '" + cadast.cd_paciente + "','" + cadast.cro + "' ,'" + cadast.cd_procedimento + "')";
again to:
insert
and I modified it in the field of string inserir = "INSERT INTO consultas (Dataa,Horario, cd_paciente, cro, cd_procedimento) values (str_to_date('" + cadast.Dataa + "','%Y-%m-%d %h:%i:%s %p'),'"+cadast.Horario+ "', '" + cadast.cd_paciente + "','" + cadast.cro + "' ,'" + cadast.cd_procedimento + "')";
to see if the problem was in it:
cadast.Dataa=
Convert.ToDateTime(monthCalendar1.SelectionStart.Date.ToString("%Y-%m-%d %h:%i:%s%p"));
He gave the following error :
The string was not recognized as a valid DateTime. There is an unknown word that starts at index 0.
It also did not work already tried in all possible ways and so far I have not succeed, can anyone help me?