title: "Specified cast is not valid" when populating DataTable from OracleDataAdapter.Fill()
body: <p>I can't seem to find this question anywhere on Google (or StackOverflow), which really surprised me, so I'm putting it on here to help others in the same situation.</p>
  
  <p>I have a SQL query which runs fine on Oracle Sql Developer, but when I run it through <code>C#</code> using<code>adapter.Fill(table)</code> to get the results, I get <code>Specified cast is not valid</code> errors (<code>System.InvalidCastException</code>).</p>
  
  <p>Here is cut-down version of the C# code:</p>
  
  <pre><code>var resultsTable = new DataTable();
  
  using (var adapter = new OracleDataAdapter(cmd))
  {
      var rows = adapter.Fill(resultsTable);  // exception thrown here, but sql runs fine on Sql Dev
  
      return resultsTable;
  }
  </code></pre>
  
  <p>And here is a simplified version of the SQL:</p>
  
  <pre><code>SELECT acct_no, market_value/mv_total
  FROM myTable
  WHERE NVL(market_value, 0) != 0
  AND NVL(mv_total, 0) != 0
  </code></pre>
  
  <p>If I remove the division clause, it doesn't error - so it's specific to that.  However, both market_value and <code>mv_total</code> are of type Number(19,4) and I can see that the Oracle adapter is expecting a decimal, so what cast is taking place?  Why does it work on SqlDev but not in C#?</p>