Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
4 replies Latest Post - ‏2013-01-23T11:10:36Z by SystemAdmin
SystemAdmin
SystemAdmin
2826 Posts
ACCEPTED ANSWER

Pinned topic OverflowException when reading BLOB with iSeries Access ODBC Driver

‏2013-01-03T13:30:42Z |
Hello,

I am using an ODBC driver in .NET with IBM DB2/400.
The driver is called "iSeries Access ODBC Driver" (CWBODBC.dll).
It's working fine with CWBODBC.dll 32 bits (version 12.0.2.0).
With CWBODBC.ddl 64 bits (version 12.64.2.0) however, i'm getting an "Overflow Exception" each time i try to read a "BLOB" column.

So it seems there's a bug with ODBC 64 bits when it reads BLOB, whereas there's no problem with the 32 bits driver.

Is this a known issue ? Do you know how to fix this problem ?

Thanks in advance for you help.

Cheers,
AE.



Below, a sample code where the problem appears if it's compiled in x64


using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.Odbc; using System.Reflection; using System.Diagnostics;   namespace TestOdbc 
{ 

class Program 
{ 

static 

void Main(string[] args) 
{ Console.WriteLine(
"START");   using (OdbcConnection dbConnection = 

new OdbcConnection(
"driver={iSeries Access ODBC Driver};System=172.17.1.10;Database=Xxxx;hostname=172.17.1.10;protocol=TCPIP; uid=Yyy; pwd=Zzz")) 
{ dbConnection.Open();   OdbcCommand dbCommand = dbConnection.CreateCommand(); dbCommand.CommandText = 
"SELECT A_BLOB_COLUMN FROM SCHEME.A_TABLE"; OdbcDataReader dbReader = dbCommand.ExecuteReader();   

while (dbReader.Read()) 
{ 
// It throw an exception if the program is x64 

byte[] blob = (

byte[])dbReader.GetValue(0); 
}   dbReader.Close(); dbCommand.Dispose(); dbConnection.Close(); 
}   Console.WriteLine(
"<press any key to stop>"); Console.ReadKey(); 
} 
}
Updated on 2013-01-23T11:10:36Z at 2013-01-23T11:10:36Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    2826 Posts
    ACCEPTED ANSWER

    Re: OverflowException when reading BLOB with iSeries Access ODBC Driver

    ‏2013-01-17T09:02:53Z  in response to SystemAdmin
    No idea ? We are really stuck with this problem.
    Any help would be greatly appreciated.
    • SystemAdmin
      SystemAdmin
      2826 Posts
      ACCEPTED ANSWER

      Re: OverflowException when reading BLOB with iSeries Access ODBC Driver

      ‏2013-01-22T09:13:05Z  in response to SystemAdmin
      More informations about versions :

      • IBM System i Access for Windows V6R1M0 with latest patch SI42423
      • cwbodbc.dll : 12.64.5.0
  • ldubois
    ldubois
    61 Posts
    ACCEPTED ANSWER

    Re: OverflowException when reading BLOB with iSeries Access ODBC Driver

    ‏2013-01-22T20:30:12Z  in response to SystemAdmin
    A simple test worked for be using both 32-bit and 64-bit. Without seeing a call stack or more information about your environment, it's not possible to help. I suggest you open a problem report to IBM Service.
    • SystemAdmin
      SystemAdmin
      2826 Posts
      ACCEPTED ANSWER

      Re: OverflowException when reading BLOB with iSeries Access ODBC Driver

      ‏2013-01-23T11:10:36Z  in response to ldubois
      Thank you for your help.

      I don't know if it can help you, but here are more informations.

      The database column is a "BLOB, length 10485760". Database is AS/400 V6R1M0.

      The program is running under windows 7. It uses .NET framework v4.

      Here is the stack trace of the .NET program, when crashing :

      System.OverflowException was unhandled
      Message=L'opération arithmétique a provoqué un dépassement de capacité.
      Source=System.Data
      StackTrace:
      à System.Data.Odbc.OdbcDataReader.GetSqlType(Int32 i)
      à System.Data.Odbc.OdbcDataReader.GetValue(Int32 i)
      à TestOdbc.Program.Main(String[] args) dans C:...\Program.cs:ligne 38
      à System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
      à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
      à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
      à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
      à System.Threading.ThreadHelper.ThreadStart()
      InnerException: