title: How to prevent ADO.NET from altering double values when it reads from Excel files
body: <p>I have the following rows in my Excel input file:</p>
  
  <pre><code>Column1       Column2
  0-5           3.040 
  6             2.957 
  7             2.876
  </code></pre>
  
  <p>and the following code which uses ADO.NET to read it:</p>
  
  <pre><code>string fileName = "input.xls";
  var connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=Excel 8.0;", fileName);
  var dbConnection = new OleDbConnection(connectionString);
  dbConnection.Open();
  try
  {
      var dbCommand = new OleDbCommand("SELECT * FROM [Sheet1$]", dbConnection);
      var dbReader = dbCommand.ExecuteReader ();
  
      while (dbReader.Read())
      {
          string col1 = dbReader.GetValue(0).ToString();
          string col2 = dbReader.GetValue(1).ToString();                 
      }                
  }
  finally
  {
      dbConnection.Close();
  }
  </code></pre>
  
  <p>The results are very disturbing.  Here's why:</p>
  
  <p>The values of each column in the first time through the loop:</p>
  
  <pre><code>col1 is empty (blank)
  
  col2 is 3.04016411633586
  </code></pre>
  
  <p>Second time:</p>
  
  <pre><code>col1 is 6
  
  col2 is 2.95722928448829
  </code></pre>
  
  <p>Third time:</p>
  
  <pre><code>col1 is 7
  
  col2 is 2.8763272933077
  </code></pre>
  
  <p>The first problem happens with col1 in the first iteration.  I expect <strong>0-5</strong>.  The second problem happens at every iteration with col2 where ADO.NET obviously alters the values as it reads them.  How to stop this mal-behavior?  </p>