views:

671

answers:

3

Hello!

I am running a service that does some computation and communicates with an ms sql server every minute or so (24/7, uptime is very important) and writes to error log if anything funny happens (like a timeout or lost connection).

This works great, however once in a while I will get this error:

Arithmetic operation resulted in an overflow.

Since this is run on client's side, and the exception has only occurred 3 times since the project has been launched (a couple of months now) this would be extremely hard to catch and debug.

I am using OleDbDataAdapter to communicate with the server. The data being received from the server was not special in any way, that I am aware of at least! Data should never exceed field sizes etc, so I can't really think of a reason for this error to occur. Again this is extremly hard to verify since I all I get is the error message.

My question is: Why does this error usually accrue? I have been unable to find any real information about it on the web, so if someone could supply me with some information, that would be very much appreciated.

Thank you!

EDIT: A careful read through the error report showed me that this error has actually occurred during the Fill of DataTable object. Code looks something like this:

DataTable.Clear();
try
{
    oledbdataAdapter.Fill(DataTable, sqlString);
}
 catch (Exception e)
{
    //error has occured, report
}

Can anyone make sense of this?

EDIT2: I have just thought of this ... Is it possible this exception would be thrown because the system doesn't have enough system resources to complete the Fill? This is the only reason I can think of that would explain the exception occurring. It would also explain why it only occurs on some servers and never occurs on dev server ...

EDIT3: Here is the whole exception in case it gives anyone any more insight:

System.OverflowException: Arithmetic operation resulted in an overflow.
   at System.Data.DataTable.InsertRow(DataRow row, Int32 proposedID, Int32 pos, Boolean fireEvent)
   at System.Data.DataTable.LoadDataRow(Object[] values, Boolean fAcceptChanges)
   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(DataSet dataSet, String srcTable, 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(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
   at INDAZajemService.INDAZajem.FillDataSet()
+1  A: 

If you are doing calculations on aggregations on the data then it would appear to be resulting in bigger results then the table structure is expecting.

Lima
+1  A: 

It usually happens when you have a number that is too big or too small to fit into a certain data type. So if you had, say, the number 120398018209571037 and tried to put it into an Int32, you would get this error. You'll need to put some more information in your code about where this is happening in order to pin it down. Good luck!

Dave Markle
Thank you. I will need it since it happens extremly rearly and values are not expected to get anywhere near their data type limitations.
Rekreativc
A: 

First, sorry by my english. You see I was doing a select and fill a dataadapter with the results. This code is inside a loop and before loop end I clear my DataTable :varDataTable.Clear()

ex: varStrSQL = "select * from my_table where field_whatever = 2 and id_fk = 4"

varDataAdapter = New SqlDataAdapter(varStrSQL, MyConexion) varDataAdapter.Fill(varDataTable) varDataAdapter.Dispose()

But after a 65xxx records I recieved the error Arithmetic operation resulted in an overflow.

I'm not sure but I think the datatable was "dimensioned" with the initial results, obviously mi first records were integer..

To solve this I don't clear the DataTableTasas, I release it. varDataTableTasas = Nothing varDataTableTasas = New Data.DataTable

Hope this help.

Sebastián