title: How do I show a message box if the username is not in a database? C#
body: <p>Hi all I have a University project and I am coding a login screen, my text book is far too vague and I can't figure out how to show a message box if the user name is not inside the database. Here is my code:</p>
  
  <pre><code>public void login()
          {
              //try
              //{
                  var tbl = from s in this.database1DataSet.employee
                            where s.Username == userNameBox.Text
                            select s;
  
                  foreach (var s in tbl)
                  {
                      if (s.Username == userNameBox.Text &amp;&amp; s.Password == passwordBox.Text)
                      {
                          MessageBox.Show("Access granted welcome " + s.fName);
                          this.Close();
                      }
                      else
                      {
                          MessageBox.Show("Access denied invalid login details");
                      }
  
                  }
              //}
              /*catch (SyntaxErrorException)
              {
                  MessageBox.Show("User Does not exist");
              }*/`enter code here`
  </code></pre>