title: C# SqlDataReader No data exists for the row/column
body: <p>I've been away from programming for a while but recently I've got a need for it.</p>
  
  <p>I have a problem with SQL DataReader using Sql Server Compact Edition 4.0 (VS2012 Built-in).</p>
  
  <pre><code>string connstring = "Data Source=C:\\..(Path Here)..\\VacationsDB.sdf";
  SqlCeConnection conn = new SqlCeConnection(connstring);
  string strSQL = "SELECT * FROM Vacation WHERE VacationNo = @val";
  
  using (SqlCeCommand cmd = new SqlCeCommand(strSQL, conn))
  {
      //read search value from from text field
      cmd.Parameters.AddWithValue("@val", vacationno_txt.Text);
      conn.Open();
  
      SqlCeDataReader reader = cmd.ExecuteReader();
      fname_txt.Text = reader.GetString(0);
      mname_txt.Text = reader.GetString(1);
      /*
       * .. snip
       */
      vacationno_txt.Text = reader.GetString(11);
      conn.Close();
  }
  </code></pre>
  
  <p>I keep getting the error:
  "InvalidOperationException was Unhandled. No data exists for the row/column." And the error points at
      fname_txt.Text = reader.GetString(0);</p>
  
  <p>But there is actually data there because the "Submit" button with all it's code is working and I've checked it in the database table itself.</p>
  
  <p>Any tips? Thank you.</p>