private void txtName_Leave(object sender, EventArgs e) { Community.DBLayer DBLayer = new Community.DBLayer(); string ID = txtFCardNo.Text; string Name = txtName.Text; bool result = DBLayer.TRANSFER(ID, Name); if (txtName.Text == "" || txtFCardNo.Text == "00000") { // MessageBox.Show("Please fill the field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (result) { try { string valuee = txtName.SelectedValue.ToString(); SqlConnection con = new SqlConnection(DBLayer.CON_string); SqlCommand cmd = new SqlCommand("Select FatherName,HusbandName,Gender,LeaderRelation,DOB,AgeGroup FROM tblFamilyMember WHERE FamilyMemberID = " + valuee, con); con.Open(); cmd.CommandType = CommandType.Text; SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { reader.Read(); txtFName.Text = reader.GetValue(0).ToString(); cmbGender.Text = reader.GetValue(2).ToString(); cmbRelation.Text = reader.GetValue(3).ToString(); cmbAgeGroup.Text = reader.GetValue(5).ToString(); DOB = reader.GetValue(4).ToString(); txtGFName.Text = reader.GetValue(1).ToString(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Member Not Found!!!", "Unable to Search", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }