This is my code
- protected void btnUpdate_Click(object sender, EventArgs e)
- {
- DateTime admissionDate = DateTime.ParseExact(txtAddmissionDate.Text, "dd/MM/yyy y", CultureInfo.InvariantCulture);
- DateTime examDate = DateTime.ParseExact(txtExamDate.Text, "dd/MM/yyyy", Culture Info.InvariantCulture);
- DateTime certificateDate = DateTime.ParseExact(txtCertificateDate.Text, "dd/MM/ yyyy", CultureInfo.InvariantCulture);
-
- SqlConnection cs = new SqlConnection(ConfigurationManager.ConnectionStrings["tr avelConnectionString"].ConnectionString);
- String str = "UPDATE [tbl_training_details] SET [service_agent_id] = '" + ddlServiceAgentList.SelectedValue + "',[training_addmission_date] = '" + admissionDate + "',[training_exam_date] = '" + examDate + "',[training_certificate_no] = '" + txtCertificateNo.Text + "',[training_certificate_date] = '" + certificateDate + "',[status_id] = '" + ddlStatus.SelectedValue + "',[comment] = '" + txtComment.Text + "'WHERE [passenger_id] = " + txtPassengerName.Text;
- SqlCommand sc = new SqlCommand(str, cs);
- cs.Open();
- sc.ExecuteNonQuery();
- cs.Close();
- }
When I click update button "String was not recognized as a valid DateTime." Error Happen. How Should Fix the problem. Please help.
Thanks