When I try to update the dates "The conversion of a varchar data type to a datetime data type resulted in an out-of-range value" error is occurred. How can I fix this issue.
c# code
------------
- SqlConnection cs = new SqlConnection(ConfigurationManager.ConnectionStrings["travelConnectionString"].ConnectionString);
- String str = "UPDATE [tbl_training_details] SET [service_agent_id] = '" +
- ddlServiceAgentList.SelectedValue + "',[training_addmission_date] = '" + txtAddmissionDate.Text + "',[training_exam_date] = '" + txtExamDate.Text + "',[training_certificate_no] = '" + txtCertificateNo.Text + "',[training_certificate_date] = '" + txtCertificateDate.Text + "',[status_id] = '" + ddlStatus.SelectedValue + "',[comment] = '" + txtComment.Text + "'WHERE [passenger_id] = " + txtPassengerName.Text;
- SqlCommand sc = new SqlCommand(str, cs);
- cs.Open();
- sc.ExecuteNonQuery();
- cs.Close();
str value I got from this code is
- str = "UPDATE [tbl_training_details] SET [service_agent_id] = '0',[training_addmission_date] = '29/09/2016',[training_exam_date] = '20/10/2016',[training_certificate_no] = '5rfde',[training_certificate_date] = '2/11/2016',[status_id] = '14',[comment] = '5gfds'WHERE [passenger_id] = 10413"
Thanks