protected void Button2_Click(object sender, EventArgs e) { Label8.Text = ""; DateTime dt; string dateTime = TextBox5.Text + " " + TextBox6.Text; try { if (string.IsNullOrWhiteSpace(TextBox5.Text) || string.IsNullOrWhiteSpace(TextBox6.Text)) { throw new Exception("Appointment Date and Appointment Time cannot be empty"); } else if (!DateTime.TryParse(dateTime, out dt)) { throw new Exception("Appointment date format should be: yyyy/MM/dd and appointment time format should be: HH:mm:ss."); } ADODatabaseService adodbs = new ADODatabaseService(); Boolean result = adodbs.AppointmentReschedule(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text, Convert.ToDateTime(dateTime)); if (result == true) { Label8.Text = "Updated successfully"; } } catch (Exception ex) { Label8.Text = ex.Message; } }