private void button1_Click(object sender, EventArgs e) { int count = 0; int count2 = 0; Validation val = new Validation(); if (val.validateNum(textBox1.Text, "Member ID")) { string Query = "select * from membership where mID = '" + Convert.ToInt32(textBox1.Text) + "'"; SqlCommand cmd = new SqlCommand(Query, conn); SqlDataReader reader; try { conn.Open(); reader = cmd.ExecuteReader(); while (reader.Read()) { count++; label1.Text = reader["indexNo"].ToString(); label10.Text = reader["mID"].ToString(); label7.Text = reader["mName"].ToString(); label11.Text = reader["mAddress"].ToString(); label12.Text = reader["mContactNo"].ToString(); label13.Text = reader.GetDateTime(5).Date.ToString("dd-MM-yyyy"); memDate = reader.GetDateTime(5).Date; } conn.Close(); } catch (Exception ex) { MessageBox.Show("Member Not Found"); } string Query2 = "select * from borrow where mID = '" + Convert.ToInt32(textBox1.Text) + "'"; SqlCommand cmd2 = new SqlCommand(Query2, conn); SqlDataReader reader2; try { conn.Open(); reader2 = cmd2.ExecuteReader(); while (reader2.Read()) { count2++; } conn.Close(); } catch (Exception ex) { MessageBox.Show("Member Not Found"); } if (count2 == 0) { label16.Text = "No book to return"; } else { label16.Text = "Please return the book"; } if (count != 0) { groupBox2.Show(); } else { MessageBox.Show("Member Not Found"); textBox1.Text = ""; } } val = null; GC.Collect(); }