title: Reading "real" data type in a SQL Server database in C#
body: <p>I have a method that pulls down data from a SQL Server Compact db:</p>
  
  <pre><code>// Open the same connection with the same connection string.
  using (SqlCeConnection con = new SqlCeConnection(DatabaseControl.conString))
  {
     con.Open();
     // Read specific values in the table.
     using (SqlCeCommand com = new SqlCeCommand("SELECT Result FROM CpuResults WHERE Date = @date", con))
     {
        List&lt;float&gt; results = new List&lt;float&gt;();
        com.Parameters.AddWithValue("date", Form1.date);
        SqlCeDataReader reader = com.ExecuteReader();
  
        while (reader.Read())
        {
           float resultsoutput = reader.GetInt32(0);
           results.Add(resultsoutput);
        }
  </code></pre>
  
  <p>The "type" for results in the "Result" column on cpuResults is defined as <code>Real</code>. I am trying to get this data into a float format as the data within the <code>Result</code> column is e.g. 0.02 and 1.23 etc. Although when I run my method I get:</p>
  
  <blockquote>
    <p>Specified cast is not valid.</p>
  </blockquote>
  
  <p>If I change the data type of column <code>Result</code> to int, the problem does not happen..</p>