title: System.IndexOutOfRangeException error SQL SELECT query unable to read the data selected from my table
body: <p>I have my SELECT statement on SQL and am just trying to view what was retrieved from the table to check if it is working however I have run into a problem!</p>
  
  <p>I am unsure why my code does not work, whenever I try and run the code an error comes up saying: System.IndexOutOfRangeException and I can't seem to find a solution to this.</p>
  
  <p>I'd be very grateful for any help! </p>
  
  <pre><code>public partial class CurrentlySetTestForm : Form
  
  {
      Timer loopTimer = new Timer();
      private string CurrentQuestionID { get; set; }
      private string QuestionSpace { get; set; }
      public CurrentlySetTestForm()
      {
          InitializeComponent();
      }
  
      private void CurrentlySetTestForm_Load(object sender, EventArgs e)
      {
  
          string y = GlobalVariableClass.Signedinteacher;
  
          Convert.ToInt32(y);
  
          string connectionString = ConfigurationManager.ConnectionStrings["myconnectionstring"].ConnectionString;
          SqlConnection connect = new SqlConnection(connectionString);
  
          connect.Open();
  
          SqlCommand command18 = new SqlCommand("SELECT MIN([QuestionID]) FROM QuestionStudentAssociation WHERE ( [StudentID]=@Signedinstudent AND [StudentAnswer]=NULL )", connect);
          command18.Parameters.AddWithValue("@Signedinstudent", y);
  
          var reader = command18.ExecuteReader();
          while (reader.Read())
          {
              CurrentQuestionID = reader["QuestionID"].ToString();
              MessageBox.Show(CurrentQuestionID);
  
          }
  
           }
      }
  </code></pre>