protected void Button1_Click(object sender, EventArgs e) { Label8.Text = ""; try { if (string.IsNullOrWhiteSpace(TextBox1.Text) || string.IsNullOrWhiteSpace(TextBox2.Text) || string.IsNullOrWhiteSpace(TextBox3.Text) || string.IsNullOrWhiteSpace(TextBox4.Text)) { throw new Exception("Patient's name and Doctor's name cannot be empty"); } ADODatabaseService adodbs = new ADODatabaseService(); DataSet result = adodbs.GetAppointment(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text); if (result != null) { string[] dateTime = result.Tables[0].Rows[0]["Appointment date & time"].ToString().Split(' '); TextBox5.Text = dateTime[0]; TextBox6.Text = dateTime[1]; TextBox7.Text = result.Tables[0].Rows[0]["Clinic name"].ToString(); TextBox1.Enabled = false; TextBox2.Enabled = false; TextBox3.Enabled = false; TextBox4.Enabled = false; TextBox7.Enabled = false; } else { Label8.Text = "Not found"; } } catch (Exception ex) { Label8.Text = ex.Message; } }