Insert DateTime in a field
I have the next code:
SqlCommand command = new SqlCommand();
command.CommandText = "INSERT INTO Custumers (Num, Name, Address,City, State, BirthdayDate) VALUES (" + txtNum.Text + "," + txtName.Text + "," + txtAddress.Text + "," + txtCity.Text + "," + txtState.Text + "," + dtpBirthdatDate.Value.Date + ")";
command.ExecuteNonQuery();
dtpBirthdayDate is a DateTimePicker Component.
When the command is executed the next error is ocurred:
Line 1: Incorrect syntax near '12'.
Any TextBox have the "12" string n' the dtpBirthdayDate (DateTimePicker) have {7/13/2004}.
But when I start the application step by step, I can see that the dtpBirthdayDate value is 07/13/2004 12:00:00 a.m.
may be this is the problem, but what can I do?
can sombody help me?
Carlos SanchezPosted Jul 28, 2004, 2:53 PM
Carlos SanchezPosted Jul 16, 2004, 3:49 PM
Giovanni BejarascoPosted Jul 16, 2004, 9:15 AM
Carlos SanchezPosted Jul 13, 2004, 1:23 PM
Adam ErstellePosted Jul 13, 2004, 12:47 PM