title: exam math from data using OLEDB
body: <p>I'm trying to make an exam form. It is suppose to take a question from different tables in my file, and by clicking <code>Q1button</code> to check the answer and print a suitable message. In addition, it is suppose to ask the user 8 questions, and update the answer (if it was answered correctly) in <code>counterCorrectAns</code>. By clicking <code>Q1button</code> it is updating the textboxes in random question from specific table.</p>
  
  <pre><code>private int randomQues=0,number=1,counterCorrectAns=0;
  private string correctAns = "";
  
  void SetQues1Box(int number)
  {
      string whatTake="",fromWhere="",autoNum="";
  
      from.Text =""+ number;
      to.Text = "" + 8;
      string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\hodaya\\Desktop\\Project.accdb";
  
      using (OleDbConnection connection = new OleDbConnection(connectionString))
      {
          switch (number)
          {
              case 1: whatTake = "misHQueA, mishAnsA"; fromWhere = "mishvaotA"; autoNum = "mishAnum"; break;
              case 2: whatTake = "misHQueB, mishAnsB"; fromWhere = "mishvaotB"; autoNum = "mishBnum"; break;
  
          }
          string sql = "SELECT " + whatTake + " FROM " + fromWhere + " WHERE " + autoNum + "=?";
  
          Random r = new Random();
          randomQues=r.Next(1, 25);
          using (OleDbCommand command = new OleDbCommand(sql, connection))
          {
              connection.Open();
              command.Parameters.AddWithValue(autoNum, randomQues);
              OleDbDataReader reader = command.ExecuteReader();
              reader.Read();
              q1Box.Text = reader.GetString(0);
              correctAns = ("" + reader.GetInt32(1));
              connection.Close();
      //**// }
          }
      }
  }
  
  private void Q1Button_Click(object sender, EventArgs e)
  {
      string exp;
  
      if (number &lt;= 8)
      {
          if (ans1Box.Text == correctAns)
          {
              counterCorrectAns++;
              exp = "correct answer";
          }
          else
              exp = "'wrong answer";
          MessageBox.Show(exp);
          number = number + 1;
          SetQues1Box(number);
      }
      else
      {
          if (counterCorrectAns &gt;= 4)
              MessageBox.Show("your great");
          else
              MessageBox.Show("you are need more practice");
          this.Close();
      }
  
  }
  </code></pre>
  
  <p>The error that I get :<code>COM object that has been separated from its underlying RCW cannot be used.</code> in the line with //**// in its beginning.</p>