title: C# Check if the username is not null or empty nor already taken
body: <p>As i said, I want to check in the Register that the username isn't null, or empty<br>
  nor already taken. </p>
  
  <pre><code>    static SqlConnection Con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=heres_the_path;Integrated Security=True");
      static string name,pass,email;
      static DataTable dt = new DataTable();
  </code></pre>
  
  <p>Please help me fix the code, the problem is somewhere here:</p>
  
  <pre><code>static bool IsUsernameAlreadyTaken(string name)//Username Checker
      {
          SqlDataAdapter sda = new SqlDataAdapter("SELECT count(*) FROM Login WHERE Nev='" + name + "'", Con);
          sda.Fill(dt);
          if (dt.Rows[0][0].ToString() == "1") return true;
          else return false;
      }
  </code></pre>
  
  <p>Or in this while loop:</p>
  
  <pre><code>static void Register() {  
          Console.WriteLine("What will be your username?");
          while (string.IsNullOrEmpty(name) &amp;&amp; IsUsernameAlreadyTaken(name)==false)
          {
              name = Console.ReadLine();
              if (IsUsernameAlreadyTaken(name))
              {
                  Console.WriteLine("That's already taken");
              }
              if (string.IsNullOrEmpty(name))
              {
                  Console.WriteLine("Why?");
              } 
          }
  }
  </code></pre>
  
  <p>Now if I give the program a name which already exist in the database it doesn't tell me that it's already taken, just continuous.</p>