title: How to manage the mysql connection in correct way without getting a error
body: <p>I am new to the C# and My method showing a error in <code>try catch</code>  <code>connection is already open</code> code as follow, when I closed it from Class method then Form getting a error <code>invalid connection</code>. here if put all code in FORM it is working. but here I get <code>MysqlDataReader</code> as a return value. how can I solve this error.</p>
  
  <p>CLASS</p>
  
  <pre><code>   //select all categories
      public MySqlDataReader SelectCategory() {
  
          try
          {
              MySqlCommand cmd = connection.CreateCommand();
              cmd.CommandText = "SELECT * FROM categories WHERE online = 1";
  
              connection.Open();
              MySqlDataReader categories = cmd.ExecuteReader();
              return categories;
          }
  
          catch (Exception ex) {
              MessageBox.Show(ex.Message);
              return null;
          }
  
  
      }
  </code></pre>
  
  <p>FORM</p>
  
  <pre><code>    public void show()
      {
          MySqlDataReader rd = db.SelectCategory();
  
          try
          {
              while (rd.Read())
              {
                  listBox1.Items.Add(rd.GetString(1));
              }
          }
  
          catch (Exception ex) {
              MessageBox.Show(ex.Message);
          }
  
      }
  </code></pre>