title: check for same user name in database 3
body: <p>i just want to check whether that user  exist or not and if not then save in the database else show error message user already exist
  before i used this command works perfectly</p>
  
  <pre><code>SqlCommand cmd = new SqlCommand("Select count(*) from cntc_employee where emp_alias= @alias", con);
  cmd.Parameters.AddWithValue("@alias", this.alias.Text);
  con.Open();
  
  if(Convert.ToInt32(cmd.ExecuteScalar()) &gt; 0)
  {            
      errorProvider1.SetError(alias,"Alias Already exist");
      return true;
  }
  else
  {
      return false;
  }
  </code></pre>
  
  <p>but in 3 tier i dont know how to use executescalar in my bll class in if ()section
  in my bll class</p>
  
  <pre><code>private bool UserNameCheck(string alias) 
  {
      if (??)
          throw new Exception("Alias Already exist");
      else
          return true;
  }
  </code></pre>
  
  <p>in my dal class</p>
  
  <pre><code>public void UserNameCheck(string alias)
  {
      string query6;
      try
      {
          OpenCnn();
  
          query6 = "Select count(*) from cntc_employee where emp_alias= '" + alias + "' ";
          cmd = new SqlCommand(query6, con);
          cmd.ExecuteNonQuery();
      }
      catch (Exception ex)
      {
          throw ex;
      }
      finally
      {
          CloseCnn();
      }
  }
  </code></pre>