title: DataAdapter.Fill() throws overflow exception on loading large decimal values
body: <p>I am trying to load large decimal values from MySQL and Oracle database which results in exception. I understand that when it is trying to convert value into decimal datatype of .Net then it results in exception but what is the way to read such huge values from database?</p>
  
  <p><strong>Exception from MySQL database</strong></p>
  
  <blockquote>
    <p>System.Number.ParseDecimal(String value, NumberStyles options,
    NumberFormatInfo numfmt)   at System.Convert.ToDecimal(String value,
    IFormatProvider provider)   at
    MySql.Data.Types.MySqlDecimal.MySql.Data.Types.IMySqlValue.get_Value()
    at MySql.Data.MySqlClient.MySqlDataReader.GetValue(Int32 i)   at
    MySql.Data.MySqlClient.MySqlDataReader.GetValues(Object[] values)   at
    System.Data.ProviderBase.SchemaMapping.LoadDataRow()   at
    System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping) 
    at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset,
    DataTable datatable, String srcTable, DataReaderContainer dataReader,
    Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn,
    Object parentChapterValue)   at
    System.Data.Common.DataAdapter.Fill(DataTable[] dataTables,
    IDataReader dataReader, Int32 startRecord, Int32 maxRecords)   at
    System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
    DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
    srcTable, IDbCommand command, CommandBehavior behavior)   at
    System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32
    startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior
    behavior)   at System.Data.Common.DbDataAdapter.Fill(DataTable
    dataTable)</p>
  </blockquote>
  
  <p><strong>Exception from Oracle database</strong></p>
  
  <blockquote>
    <p>System.OverflowException: Arithmetic operation resulted in an
    overflow. at Oracle.DataAccess.Types.DecimalConv.GetDecimal(IntPtr
    numCtx) at Oracle.DataAccess.Client.OracleDataReader.GetDecimal(Int32
    i) at Oracle.DataAccess.Client.OracleDataReader.GetValue(Int32 i) at
    Oracle.DataAccess.Client.OracleDataReader.GetValues(Object[] values)
    at System.Data.ProviderBase.SchemaMapping.LoadDataRow() at
    System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)
    at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset,
    DataTable datatable, String srcTable, DataReaderContainer dataReader,
    Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn,
    Object parentChapterValue) at
    System.Data.Common.DataAdapter.Fill(DataTable[] dataTables,
    IDataReader dataReader, Int32 startRecord, Int32 maxRecords) at
    Oracle.DataAccess.Client.OracleDataAdapter.Fill(DataTable[]
    dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command,
    CommandBehavior behavior) at
    System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)</p>
  </blockquote>
  
  <p>Here is my sample code in VB.Net</p>
  
  <pre><code>Using comm = createCommand(strSql, CommandType.Text,60)
     Using Da = _providerFactory.CreateDataAdapter
         Da.MissingSchemaAction = MissingSchemaAction.Add
         Da.SelectCommand = comm
         Da.SelectCommand.CommandTimeout = 60
         Dim dt As New DataTable
         Da.Fill(dt)                  
         Return dt
     End Using
  End Using
  </code></pre>
  
  <p>Sample value which I am trying to read</p>
  
  <blockquote>
    <p>792281625142643375935439503351.000000000000000000000000000012</p>
  </blockquote>
  
  <p>I found various other links such as <a href="https://stackoverflow.com/questions/7549058/sqldataadapter-fill-conversion-overflow">this</a> one for my problem but none works for me. I am open to read the value as string and do conversions later on.</p>
  
  <p>Edit 1:</p>
  
  <p>Database queries are not under my control so I cannot edit the queries passed by the clients. Also I provide support for multiple database like MySql, Oracle, DB2, Sqlite, Sqlserver etc using factory pattern for creating DataAdapter, Hence it won't be feasible to edit the queries. My tool fetch data using queries provided by users and provide the output in xml format.</p>
  
  <p>Edit 2:</p>
  
  <p>I tried using <strong>Java</strong> to fetch the data and <strong>resultset.getString("column_name")</strong> is working fine to fetch data as String. Do we have something similar in .Net? </p>
  
  <p>DataReader.GetString() provided in .Net is not working.</p>