protected void btnAdd_Click(object sender, EventArgs e) { lblEMsg.Visible = false; string[] Catg; try { string sql = "SELECT COUNT(*) FROM CATEGORY WHERE CATEGORY_NAME = '" + txtCName.Text + "' And Status = 'A'"; SqlDataReader sdr; Profile pro = new Profile(); sdr = pro.ReturnMDetails(sql); sdr.Read(); int RegNo = (int)sdr[0]; if (RegNo > 0) { lblEMsg.Text = "Category Name already exists."; lblEMsg.Visible = true; sdr.Close(); return; } else { Catg = new string[15]; Catg[0] = txtCategory.Text; Catg[1] = txtCName.Text; Catg[2] = txtcDesc.Text; if (chkStatus.Checked == true) { Catg[3] = "A"; } else { Catg[3] = "I"; } bool status; status = pro.AddCategory(Catg); if (status == false) { lblEMsg.Visible = true; lblEMsg.Text = "Category creation Failed"; } lblEMsg.Visible = true; lblEMsg.Text = "Category added."; ReadCategory(); txtCName.Text = ""; txtcDesc.Text = ""; } } catch (Exception ex) { throw ex; } }