title: Out of range error on SqlDataReader
body: <p>I'm using a <code>SqlDataReader</code> and get this exception when trying to read a column...</p>
  
  <blockquote>
    <p><em>System.IndexOutOfRangeException: record</em></p>
  </blockquote>
  
  <p>Here is the code...</p>
  
  <pre><code>SqlCommand select = new SqlCommand("SELECT RTRIM(LTRIM(PART_NO)) AS PART_NO, record AS CUSTOMER_NO FROM [RMAData].[dbo].[IMPORTING_ORDER_EDI] WHERE sessionID = '" + Session.SessionID + "'", connection);
  SqlDataReader reader = select.ExecuteReader();
  
  if (reader.HasRows)
  {
     while (reader.Read())
     {
         lblWebMasterMessage.Text += "record " + reader["record"].ToString() + "&lt;br /&gt;";
  ...
  </code></pre>
  
  <p>If I change the <code>lblWebMasterMessage.Text</code> to the following it works just fine...</p>
  
  <pre><code>lblWebMasterMessage.Text += "record " + reader["PART_NO"].ToString() + "&lt;br /&gt;";
  </code></pre>
  
  <p>The difference between record and <code>PART_NO</code> in the SQL Server table is that 'record' is a primary key and an <code>int</code>, <code>PART_NO</code> is a <code>varchar(100)</code>.</p>
  
  <p>The trouble is, I need the 'record' to identify the record to update it later...</p>
  
  <p>I really can't see why it can return one field and not the other?</p>