Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: arithmetic overflow by reading data via ODBC

In my actual project im reading Data from a Filemaker v14 Database. Im getting the Data like that:

command.CommandText = "SELECT * FROM CAR";

//Create new SqlDataReader object and read data from the command.
using (OdbcDataReader reader = command.ExecuteReader())
{
    /*
    * Get and cast the ID
    */
    int counter = 0;
    while (reader.Read() && counter < numberOfOrders)
    {
        SalesOrder s = new SalesOrder();
        s.abNR = reader["Auftrags Nr."].ToString();
        s.artNr = reader["Artikel nr."].ToString();
        s.quantity = reader["Menge"].ToString();
        s.city_country_Coustomer = reader["Stadt"].ToString();
    }
}

This code is running perfectly on the computer I'm developing on.

If I put my project to my IIS this error occurs:

Arithmetic operation resulted in an overflow.

in this line:s.abNR = reader["Auftrags Nr."].ToString();

I already checkt the dsn on both my computer and the server. Both seem to be the same.

The conection is created like that:

conn = new OdbcConnection("DSN=FILEMAKER1;Uid=Test;Pwd=tset");
conn.Open();

command = conn.CreateCommand();

Im looking forward to your answers!

EDIT:

This is my SalesOrder-Class:

public class SalesOrder
{
    public string abNR { get; set; }
    public string artNr { get; set; }
    public string quantity { get; set; }
    public string city_country_Coustomer { get; set; }
}

EDIT 2:

Sample Data for a SalesOrder:

Aufrags Nr. | Artikel nr. | Menge | Stadt   |
------------+-------------+-------+---------+
  168953    |   508800    |   2   | Berlin  |
------------+-------------+-------+---------+
  167996    |   508850    |   4   | München |
------------+-------------+-------+---------+
  FF8957    |   509010    |   1   | Berlin  |

EDIT 3:

[OverflowException: Die arithmetische Operation hat einen Überlauf verursacht.] System.Data.Odbc.OdbcDataReader.GetSqlType(Int32 i) +359 System.Data.Odbc.OdbcDataReader.GetValue(Int32 i) +57 System.Data.Odbc.DbCache.AccessIndex(Int32 i) +82
System.Data.Odbc.OdbcDataReader.GetValue(Int32 i) +38
Produktionscockpit.SQL.FilemakerController.getActualSalesOrders(Int32 numberOfOrders) in c:\Dev\ProductionCockpit\Produktionscockpit\SQL\FilemakerController.cs:56 Produktionscockpit.Home.addSalesOrderTabelContent() in c:\Dev\ProductionCockpit\Produktionscockpit\default.aspx.cs:79
Produktionscockpit.Home.Page_Load(Object sender, EventArgs e) in c:\Dev\ProductionCockpit\Produktionscockpit\default.aspx.cs:21
System.Web.UI.Control.LoadRecursive() +116
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2910

like image 783
Felix Gerber Avatar asked May 11 '16 14:05

Felix Gerber


1 Answers

I was reading a bit about this, and there's a problem with with connecting between 32-bit and 64-bit. Is your application being compiled for x86? Assuming you are using a 32-bit ODBC data source.

From what I see in other people with the same problem (I never experienced this) you can fix it by either moving your application to 32 bits (if the data source is 32 bits) or someone also uninstalled the 64-bit version of filemaker and installed the 32-bit.

It's likely this is the problem, but I can't really give you a proper solution since I don't know your environment.

like image 136
Itzack Avatar answered Sep 28 '22 17:09

Itzack