title: System.IndexOutOfRangeException on SQLDataReader Value Using C#
body: <p>I have a SQLDataReader that returns three integers. However, there are occasions when two of the integers will return null values.</p>
  
  <p>To get round this I wrote the following:</p>
  
  <pre><code>int shoppingCartHeadID = 0;
  int billID = 0;
  int delID = 0;
  
  conn.Open();
  reader = comm.ExecuteReader();
  if (reader.Read())
  {
         shoppingCartHeadID = Convert.ToInt32(reader["shoppingCartHeadID"]);
  
         if (!reader.IsDBNull(billID))
         {
              billID = Convert.ToInt32(reader["billID"]);
         }
  
         if (!reader.IsDBNull(delID))
         {
              delID = Convert.ToInt32(reader["delID"]);
         }                
  }
  reader.Close();
  </code></pre>
  
  <p>Unfortunately I'm still getting the error message. Any suggestions?</p>
  
  <p>PS I also tried this with no luck</p>
  
  <blockquote>
    <p>if (reader["billID"] != null)</p>
  </blockquote>