locked
Upgrade to 4.0 - "Arithmetic operation resulted in an overflow Error" - MySQL driver issue RRS feed

  • Question

  • User-1777897341 posted

    I upgraded to 4.0 and I'm now getting "Arithmetic operation resulted in an overflow Error" whenever I try to call information from the database. I'm using MySQL ODBC 5.1 for the site.

    When I first started getting the error I could only return integer values and was using the connection string:

    Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=myDataBase;User=myUsername;Password=myPassword;Option=3;

    I then started looking into it and I though it may be an issue with strings so than I tried adding the charset so it became:

    Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;charset=UTF8;Database=myDataBase;User=myUsername;Password=myPassword;Option=3;

    This ended up allowing me to call char fields, but I'm still having issues with text fields. Right now I'm testing using a basic repeater and sqldatasource.

                    <asp:Repeater ID="rptr1" DataSourceId="sqldsrc1" runat="server">
                        <ItemTemplate></ItemTemplate>
                    </asp:Repeater>
                    <asp:SqlDataSource ID="sqldsrc1"
                        connectionstring="Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;charset=UTF8;Database=myDataBase;User=myUsername;Password=myPassword;Option=3;"
                        providername="System.Data.Odbc" 
                        SelectCommand=" select text from table where key = 1;"
                    runat="server">
                    </asp:SqlDataSource>

    As you can tell, all I'm doing at this point is gathering the information from the datasource and not doing anything else with it at this point.

    I'm almost sure it's a simple driver issue at this point or a web.config issue. When I upgraded to .Net 4.0 it changes my web.config a little but I compared it with a prior version and I'm not seeing anything that looks like it would have tripped it up.



    Current web.config:


    <?xml version="1.0" encoding="UTF-8"?>
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    	<system.web>
    		<compilation debug="true" explicit="true" strict="false" targetFramework="4.0">
    		</compilation>
    		<pages controlRenderingCompatibilityVersion="4.0" clientIDMode="AutoID">
    			<namespaces>
    				<clear />
    				<add namespace="System" />
    				<add namespace="System.Collections" />
    				<add namespace="System.Collections.Generic" />
    				<add namespace="System.Collections.Specialized" />
    				<add namespace="System.Configuration" />
    				<add namespace="System.Text" />
    				<add namespace="System.Text.RegularExpressions" />
    				<add namespace="System.Linq" />
    				<add namespace="System.Xml.Linq" />
    				<add namespace="System.Web" />
    				<add namespace="System.Web.Caching" />
    				<add namespace="System.Web.SessionState" />
    				<add namespace="System.Web.Security" />
    				<add namespace="System.Web.Profile" />
    				<add namespace="System.Web.UI" />
    				<add namespace="System.Web.UI.WebControls" />
    				<add namespace="System.Web.UI.WebControls.WebParts" />
    				<add namespace="System.Web.UI.HtmlControls" />
    			</namespaces>
    		</pages>
    		<authentication mode="Windows" />
    		<globalization requestEncoding="utf-8" responseEncoding="utf-8" fileEncoding="iso-8859-15" />
    	</system.web>
    	<system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
    		<defaultDocument>
    			<files>
    				<clear />
    				<add value="index.aspx" />
    			</files>
    		</defaultDocument>
    	</system.webServer>
    </configuration>

    Prior web.config

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    	<configSections>
    		<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    			<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    				<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    				<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    					<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
    					<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    					<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    					<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    				</sectionGroup>
    			</sectionGroup>
    		</sectionGroup>
    	</configSections>
    	<system.web>
    		<compilation debug="false" strict="false" explicit="true">
    			<assemblies>
    				<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    				<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    				<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    				<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    			</assemblies>
    		</compilation>
    		<pages>
    			<namespaces>
    				<clear/>
    				<add namespace="System"/>
    				<add namespace="System.Collections"/>
    				<add namespace="System.Collections.Generic"/>
    				<add namespace="System.Collections.Specialized"/>
    				<add namespace="System.Configuration"/>
    				<add namespace="System.Text"/>
    				<add namespace="System.Text.RegularExpressions"/>
    				<add namespace="System.Linq"/>
    				<add namespace="System.Xml.Linq"/>
    				<add namespace="System.Web"/>
    				<add namespace="System.Web.Caching"/>
    				<add namespace="System.Web.SessionState"/>
    				<add namespace="System.Web.Security"/>
    				<add namespace="System.Web.Profile"/>
    				<add namespace="System.Web.UI"/>
    				<add namespace="System.Web.UI.WebControls"/>
    				<add namespace="System.Web.UI.WebControls.WebParts"/>
    				<add namespace="System.Web.UI.HtmlControls"/>
    			</namespaces>
    		</pages>
    		<authentication mode="Windows"/>
    		<httpHandlers>
    			<remove verb="*" path="*.asmx"/>
    			<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    			<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    			<add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    		</httpHandlers>
    		<httpModules>
    			<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    		</httpModules>
    	</system.web>
    	<system.codedom>
    		<compilers>
    			<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
    				<providerOption name="CompilerVersion" value="v3.5"/>
    				<providerOption name="WarnAsError" value="false"/>
    			</compiler>
    			<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
    				<providerOption name="CompilerVersion" value="v3.5"/>
    				<providerOption name="OptionInfer" value="true"/>
    				<providerOption name="WarnAsError" value="false"/>
    			</compiler>
    		</compilers>
    	</system.codedom>
    	<system.webServer>
    		<defaultDocument>
    			<files>
                  			<add value="index.aspx" />
    			</files>
    		</defaultDocument>
    		<validation validateIntegratedModeConfiguration="false"/>
    		<modules>
    			<remove name="ScriptModule"/>
    			<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    		</modules>
    		<handlers>
    			<remove name="WebServiceHandlerFactory-Integrated"/>
    			<remove name="ScriptHandlerFactory"/>
    			<remove name="ScriptHandlerFactoryAppServices"/>
    			<remove name="ScriptResource"/>
    			<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    			<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    			<add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    		</handlers>
    	</system.webServer>
    	<runtime>
    		<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    			<dependentAssembly>
    				<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
    				<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
    			</dependentAssembly>
    			<dependentAssembly>
    				<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
    				<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
    			</dependentAssembly>
    		</assemblyBinding>
    	</runtime>
    </configuration>
    

    One of my favorite things so far for 4.0 is getting rid of all that 3.5 config excess.

    Monday, April 12, 2010 8:42 PM

Answers

  • User826909406 posted

    I've stumbled uppon the exact same problem, and found the source of it within the new ASP.NET 4.0 AppPool visual studio creates after updating. You can solve this problem in IIS by changing the setting "Enable 32-bit applications" to true in the "ASP.NET 4.0 AppPool", or reasign the old AppPool and set it to use .NET 4.0.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 15, 2010 6:22 AM

All replies

  • User-1636183269 posted

    use int64 becuase it is 64 bit ,integer is 32 bit


    Tuesday, April 13, 2010 7:38 AM
  • User-1777897341 posted

    I'm not seeing anyway to convert the datareader to 64bit. 

    [OverflowException: Arithmetic operation resulted in an overflow.]
       System.Data.Odbc.OdbcDataReader.GetSqlType(Int32 i) +361
       System.Data.Odbc.OdbcDataReader.GetFieldType(Int32 i) +173
       System.Data.Common.DbEnumerator.BuildSchemaInfo() +440
       System.Data.Common.DbEnumerator.MoveNext() +232
       System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) +696
       System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) +167
       System.Web.UI.WebControls.Repeater.EnsureDataBound() +84
       System.Web.UI.WebControls.Repeater.OnPreRender(EventArgs e) +20
       System.Web.UI.Control.PreRenderRecursiveInternal() +113
       System.Web.UI.Control.PreRenderRecursiveInternal() +222
       System.Web.UI.Control.PreRenderRecursiveInternal() +222
       System.Web.UI.Control.PreRenderRecursiveInternal() +222
       System.Web.UI.Control.PreRenderRecursiveInternal() +222
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4185

    I can see from the stack trace that it's reading as 32. The driver I'm running right now is 64, but I tried the 32 bit as well. Neither is working. And it's strange since it only happens with TEXT fields.


    Tuesday, April 13, 2010 9:38 PM
  • User-1636183269 posted

    I mean to say use Int64, you are using Int32. See error:

    System.Data.Odbc.OdbcDataReader.GetSqlType(Int32 i) +361

    It crosses the int32 range.Its range is -2,147,483,648 to 2,147,483,647

    Mark as answer if it helps. 

    Tuesday, April 13, 2010 9:42 PM
  • User-1777897341 posted

    How would you change it to Int64 if I'm using the sqldatasource object. I tried using the connector/net driver which allows me to collect text fields just fine. It's the ODBC driver that's giving me issues.

    Would there be a web.config setting that could force the driver to use int64? I've been playing with options in the connectionstring. I'll continue to see if there is a way to fix this without having to rewrite all the code on the site.

    Tuesday, April 13, 2010 11:40 PM
  • User826909406 posted

    I've stumbled uppon the exact same problem, and found the source of it within the new ASP.NET 4.0 AppPool visual studio creates after updating. You can solve this problem in IIS by changing the setting "Enable 32-bit applications" to true in the "ASP.NET 4.0 AppPool", or reasign the old AppPool and set it to use .NET 4.0.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 15, 2010 6:22 AM
  • User-1777897341 posted

    Joost great job! Worked like a charm! Go figure it's the one place I didn't think of looking. lol

    Thursday, April 15, 2010 5:27 PM
  • User1805528910 posted

    Thanks it solved my issue

    I've stumbled uppon the exact same problem, and found the source of it within the new ASP.NET 4.0 AppPool visual studio creates after updating. You can solve this problem in IIS by changing the setting "Enable 32-bit applications" to true in the "ASP.NET 4.0 AppPool", or reasign the old AppPool and set it to use .NET 4.0.


    Sunday, October 31, 2010 8:57 AM