title: Check if user already exists in MySql Database with C#
body: <p>I have the following code and I would like the code to query the database:</p>
  
  <pre><code> MySqlConnection connection = new MySqlConnection(Connection);
   MySqlCommand cmd;
   connection.Open();
    try
    {
      cmd = connection.CreateCommand();
      cmd.CommandText = ("INSERT INTO edata (username) VALUES ('" + this.NewUserName.Text +"') ;");
      MySqlDataReader myReader;
      myReader = cmd.ExecuteReader();
      loading.Show();
      MessageBox.Show("Your Account Has Been Created!!");
      connection.Close();
    }
    catch (Exception ex)
    {
      MessageBox.Show(ex.Message);
    }
  </code></pre>
  
  <p>If the clients input (NewUserName.Text) is the same as the username in the database there should be an error message, otherwise there will be duplicate usernames. How can I do this?</p>
  
  <p>I have already got the connection as a string.</p>
  
  <p>Thank you in advance!!! </p>
  
  <p>PS Im a student learning C# and MySql, I am grateful for any help and advice!</p>