title: How to fix Object reference not set to an instance of an object MySql Connection Issue
body: <p>I'm creating a Application that's utilizing mysql as a database, however, when I run the program I keep getting this error:</p>
  
  <blockquote>
    <p>"Object reference not set to an instance of an object.</p>
  </blockquote>
  
  <p>On line 29 in the <code>private class registerUser()</code> where it begins as <code>String connString =....</code> is where the problem is how dow I fix it?</p>
  
  <pre><code>private void registerUser()
  {
      String connString = System.Configuration.ConfigurationManager.ConnectionStrings["SportsDBConnString"].ToString();
  
      conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
      conn.Open();
      queryStr = "";
  
      queryStr = "INSERT INTO sportsdbmlb.userregistration (firstname, middlename, lastname, email, username, password )" +
          "VALUES('"+firstnameTextBox.Text + "','"+ middlenameTextBox.Text +"','" + lastnameTextBox.Text + "','" + emailTextBox.Text +
          "','" + usernameTextBox.Text + "','" + passwordTextBox.Text + "')";
  
      cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
  
      cmd.ExecuteReader();
  
      conn.Close();
  }
  </code></pre>