An overflow occurred due to an arithmetic operation.

asp.net entity-framework mysql

Question

After updating my website on ii7 on window server 2008 from framework 3.5 to work with framework 4 i got my c# base database class stop working copmlitly with this error: "Arithmetic operation resulted in an overflow". I am working with mysql server from different server.

I did not find any solution on this so i had very sadness to role bakce to framework 3.5

here is some of my logs for this error in the event viewr on my server:


Process information: Process ID: 3680 Process name: w3wp.exe Account name: NT AUTHORITY\NETWORK SERVICE

Exception information: Exception type: OverflowException Exception message: Arithmetic operation resulted in an overflow. at DataAccess.ExecuteStringQuery(String strSQL) in d:\webSites\s2s\App_Code\DB\DataAccess.cs:line 214 at DataSelect.generalString(String rowName, String tableName, String idName, String ID) in d:\webSites\s2s\App_Code\DB\DataSelect.cs:line 48 at camsBaseShowWeb.OnPreInit(EventArgs e) in d:\webSites\s2s\App_Code\Bases\camsBaseShowWeb.cs:line 134 at System.Web.UI.Page.PerformPreInit()

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

big thanks for any halp


i got this error - no matter wich function i try to call from this code

here is my code:

using System;
using System.Data;
//using Microsoft.Data.Odbc;
using System.Data.Odbc;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public class DataAccess
{
    #region Private Variables
    private static DataAccess _DataAccess = null;
    private static object _SyncLock = new object();
    private string _strCon = "Driver={MySQL ODBC 5.1 Driver};Server=theIP;Database=theDatabase; UID=root;Password=thePassword;Option=3;";
    private OdbcConnection myConnection = null;
    #endregion

    #region Instance Method
    public static DataAccess Instance
    {
        get
        {
            lock (_SyncLock)
            {
                if (_DataAccess == null)
                    _DataAccess = new DataAccess();
                return _DataAccess;
            }
        }
    }
    #endregion

    #region Constractors
    public DataAccess()
    {
        myConnection = new OdbcConnection(_strCon);
        myConnection.Open();
    }
    #endregion

    #region Public Functions
    public OdbcDataReader ExecuteQueryReader(string strSQL)
    {
        try
        {
            OdbcCommand myCommand = new OdbcCommand(strSQL, myConnection);
            return myCommand.ExecuteReader();
        }
        catch (Exception ex)
        {
            if (Dict.IsRemote == true)
            {
                sendMail("error ExecuteQueryReader SQL s2s", strSQL, ex);
            }
            throw ex;
        }
    }

    public DataTable ExecuteQuery(string strSQL)
    {
        DataTable dt = new DataTable();
        OdbcDataAdapter objDataAdapter = null;
        try
        {
            objDataAdapter = new OdbcDataAdapter(strSQL, myConnection);
            objDataAdapter.Fill(dt);
        }
        catch (Exception ex)
        {
            if (Dict.IsRemote == true)
            {
                sendMail("error ExecuteQuery SQL s2s", strSQL, ex);
            }

            throw ex;
        }
        finally
        {
            if (objDataAdapter != null) objDataAdapter.Dispose();
        }
        return dt;
    }

    public DataView ExecuteQueryDV(string strSQL)
    {
        DataTable dt = new DataTable();
        OdbcDataAdapter objDataAdapter = null;
        try
        {
            objDataAdapter = new OdbcDataAdapter(strSQL, myConnection);
            objDataAdapter.Fill(dt);
        }
        catch (Exception ex)
        {
            if (Dict.IsRemote == true)
            {
                sendMail("error ExecuteQuery SQL s2s", strSQL, ex);
            }

            throw ex;
        }
        finally
        {
            if (objDataAdapter != null) objDataAdapter.Dispose();
        }
        return new DataView(dt);
    }

    public DataTable ExecuteLimitedQuery(string strSQL, int startRow, int rowNum)
    {
        DataTable dt;
        DataSet ds = new DataSet();
        OdbcDataAdapter objDataAdapter = null;
        try
        {
            objDataAdapter = new OdbcDataAdapter(strSQL, myConnection);
            objDataAdapter.Fill(ds, startRow, rowNum, "rowTable");
            dt = (DataTable)ds.Tables["rowTable"];
        }
        catch (Exception ex)
        {
            if (Dict.IsRemote == true)
            {
                sendMail("error ExecuteLimitedQuery SQL s2s", strSQL, ex);
            }

            throw ex;
        }
        finally
        {
            if (objDataAdapter != null) objDataAdapter.Dispose();
        }
        return dt;
    }

    public object ExecuteScalarQuery(string strSQL)
    {
        OdbcCommand myCommand = null;
        object obj = null;

        try
        {
            myCommand = new OdbcCommand(strSQL, myConnection);
            obj = myCommand.ExecuteScalar();
        }
        catch (Exception ex)
        {  
            if (Dict.IsRemote == true)
            {
                sendMail("error ExecuteScalarQuery SQL s2s", strSQL, ex);
            }

            throw ex; 
        }
        finally
        {
            if (myCommand != null) myCommand.Dispose();  
        }

        return obj;
    }

    public string ExecuteStringQuery(string strSQL)
    {
        OdbcCommand myCommand = null;
        object obj = null;

        try
        {
            myCommand = new OdbcCommand(strSQL, myConnection);
            obj = myCommand.ExecuteScalar();
        }
        catch (Exception ex)
        {
            if (myConnection.State != ConnectionState.Open)
            {
                myConnection.Open();
                if (myCommand != null) myCommand.Dispose();

                try
                {
                    myCommand = new OdbcCommand(strSQL, myConnection);
                    obj = myCommand.ExecuteScalar();
                }
                catch (Exception ex2)
                {
                    if (Dict.IsRemote == true)
                    {
                        sendMail("error - לאחר ניסיון שני ExecuteStringQuery SQL s2s", strSQL, ex2);
                    }

                    throw ex2;
                }
            }
            else
            {
                if (Dict.IsRemote == true)
                {
                    sendMail("error ExecuteStringQuery SQL s2s", strSQL, ex);
                }

                throw ex;
            }
        }
        finally
        {
            if (myCommand != null) myCommand.Dispose();
        }

        return obj != null ? obj.ToString() : string.Empty;
    }

    public int ExecuteNoneQuery(string strSQL)
    {
        OdbcCommand myCommand = null;
        int i;
        try
        {
            myCommand = new OdbcCommand(strSQL, myConnection);
            i = myCommand.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            if (Dict.IsRemote == true)
            {
                sendMail("error ExecuteNoneQuery SQL s2s", strSQL, ex);
            }

            throw ex;
        }
        finally
        {
            if (myCommand != null) myCommand.Dispose();  
        }
        return i;
    }

    public int InsertGetLastID(string strSQL)
    {
        OdbcCommand myCommand = null;
        int LastID = 0;
        object objID = null;

        try
        {
            myCommand = new OdbcCommand(strSQL, myConnection);
            if (myCommand.ExecuteNonQuery() == 1)
            {
                myCommand = new OdbcCommand("SELECT LAST_INSERT_ID()", myConnection);
                objID = myCommand.ExecuteScalar();
                if (objID != null)
                {
                    LastID = int.Parse(objID.ToString());
                }
            }
        }
        catch (Exception ex)
        {
            if (Dict.IsRemote == true)
            {
                sendMail("error InsertGetLastID SQL s2s", strSQL, ex);
            }

            throw ex;
        }
        finally
        {
            if (myCommand != null) myCommand.Dispose();  
        }
        return LastID;
    }

    private void sendMail(string title, string sql, Exception ex)
    {
        string body = string.Empty +
            "SQL:\n\n" + sql + "\n\n" +
            "Exeption:\n\n" + ex.Message + "\n\n" +
            "Stack Trace:\n\n" + ex.StackTrace + "\n\n" +
            "Source:\n\n" + ex.Source + "\n\n";

        mailSend mailS = new mailSend("theMail", "mailTo", title, body);
    }
    #endregion
}
1
0
9/21/2012 12:41:26 PM

Popular Answer

conver to boolean function does not work when 1. Development is done on 32 bit OS 2. Implementation is done on 64 bit OS

When I altered the code for Convert.ToBoolean function, It worked normally.

1
6/25/2012 9:49:29 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow