Carlos Sanchez

Carlos Sanchez

  • NA
  • 264
  • 0

Insert DateTime in a field

Jul 13 2004 12:07 PM
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?

Answers (5)