title: Comparing Database values with an input value?
body: <p>I'm attempting to create a register page for users to use.
  However, this allows users to have the same Username, in which I don't want to happen. I've wrote a piece of code, which I assumed would work but failed miserably.</p>
  
  <pre><code>Managers manager = new Managers();
  
  //Compares to database to find any duplicate usernames
  if (manager.Username == txtUsername.Text)
  {
      lblUsername.Text = "Please enter a different username!";
      lblUsername.Visible = true;
  }
  </code></pre>
  
  <p>Only gave the relevant part.</p>
  
  <p>I was wondering if someone could explain to me what I have done wrong about this? <code>Managers</code> is my database.</p>
  
  <p>Edit-
  I added in a foreach loop, however was still accepted values.</p>
  
  <pre><code>List&lt;Managers&gt; manage = new List&lt;Managers&gt;();
  Managers manager = new Managers();
  foreach (Managers m in manage)
  {
      if (manager.Username == txtUsername.Text)
      {
          lblUsername.Text = "Please enter a different username!";
          lblUsername.Visible = true;
      }
  }
  </code></pre>
  
  <p><a href="http://i.imgur.com/5DF4Mj6.png" rel="nofollow">http://i.imgur.com/5DF4Mj6.png</a> Showing the Error when program is ran</p>