title: OleDbDataReader = null
body: <p>I'm currently building a program which stores messages between users in a database and returns these messages to the user when the button below gets pressed. I'm using a SQL CE database using a <code>OleDbConnection</code> and using a <code>DataReader</code>.</p>
  
  <pre><code>private void button3_Click(object sender, EventArgs e)
  {
  
      string [] lec_name = new  string [10] ;
      string [] content = new  string [10] ; 
      string conn = "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=C:\\Users\\Leon\\Admin.sdf";
      OleDbConnection connection = new OleDbConnection(conn);
      OleDbCommand command = connection.CreateCommand();
      command.CommandText = "SELECT * FROM Contact_DB WHERE Student_ID =" + iD + " AND Direction = '" + "To the student" + "'";
  
      try
      {
          connection.Open();
      }
      catch (Exception ex)
      {
          MessageBox.Show("" + ex.Message); 
      }
  
      OleDbDataReader reader = command.ExecuteReader();
      int up = 0;
      int count = 0;
  
      while (reader.Read())
      {
          lec_name[up] = reader["Lecturer_Name"].ToString();
          content[up] = reader["Description"].ToString();
          up++;
          MessageBox.Show("The lecturer " + lec_name[count] + " has messaged you saying :" + "\n" + content[count]);
          count++;
      }
  }
  </code></pre>
  
  <p>This code works for my <code>Student</code> class but when I reuse the code with minor changes within the <code>Lecturer</code> class the <code>OledbDataReader</code> says null, anyone know why?<br>
  Btw the values being returned aren't null the reader itself is null.
  Below is the non working code.</p>
  
  <pre><code>private void button2_Click(object sender, EventArgs e)
      {
          string [] studentID = new  string [10] ;
          string [] content = new  string [10] ; 
          string conn = "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=C:\\Users\\Leon\\Admin.sdf";
              OleDbConnection connection = new OleDbConnection(conn);
              OleDbCommand command = connection.CreateCommand();
              command.CommandText = "SELECT * FROM Contact_DB WHERE Lecturer_Name =" + full + " AND Direction = '" + "To the lecturer" + "'";
              try
              {
                  connection.Open();
  
              }
              catch (Exception ex)
              {
                  MessageBox.Show("" + ex.Message); 
              }
              OleDbDataReader reader1 = command.ExecuteReader();
              int up = 0;
              int count = 0;
              while (reader1.Read())
              {
  
                   studentID[up] = reader1["Student_ID"].ToString();
                   content[up] = reader1["Description"].ToString();
                   up++;
  
              }
              MessageBox.Show("The student " + studentID[count] + " has messaged you saying :" + "\n" +content[count]);
              }
      }
  </code></pre>