title: a datareader associeted with this command is already open, it must be closed first
body: <p>i have a tablelayoutpanel that contains a combobox with article names and 2 textboxs one for quantity and the other for displaying the finalprice of the article, i want to calculate the finalprice ( price * quantity ) but all i get is a exception "a datareader associeted with this command is already open, it must be closed first" but a closed all the readers :/</p>
  
  <pre><code>private void txtQ2_TextChanged(object sender, EventArgs e)
      {
          if (sqlCon.State == ConnectionState.Closed)
              sqlCon.Open();
          try {
              int q = tableLayoutPanel1.GetRow((TextBox)sender);
              ComboBox q1 = (ComboBox)tableLayoutPanel1.GetControlFromPosition(0, q);
              String NameArt = q1.Text;
              SqlCommand cmd2 = new SqlCommand("select PriceArticle from tbl_article where NameArticle='" + NameArt + "'", sqlCon);
              SqlDataReader dr1 = cmd2.ExecuteReader();
              if(dr1.Read())
              {
                  int x = tableLayoutPanel1.GetRow(q1);
                  TextBox y1 = (TextBox)tableLayoutPanel1.GetControlFromPosition(1, x);
                  int z;
                  bool parseOK1 = Int32.TryParse(y1.Text, out z);
                  String a = dr1["PriceArticle"].ToString();
                  int j;
                  bool parseOK2 = Int32.TryParse(a, out j);
                  int w = j * z;
                  TextBox y2 = (TextBox)tableLayoutPanel1.GetControlFromPosition(2, x);
                  y2.Text = w.ToString();
              }
              dr1.Close();
          }
          catch(Exception ex)
          {
              MessageBox.Show(ex.Message, "Error");
          }
      }
  </code></pre>