0
votes

I'm reading a DB2 database in C# using ODBC, and getting an overflow when trying to access that data from a DataReader. I think the issue is that the DB2 client is not set to report the data types properly. For example, it shows character fields as being type "GRAPHIC() CCSID 13488" which is IBM gobbledygook to me. The overflow comes when .NET tries to read a field that I know is a 12-character string as an Int32.

Long ago I worked with DB2 and recall having to set properties in the client, but none of my tweaks are working. Can someone please help out?

The OS is Windows Server 2008 R2, x64 The ODBC driver is named "iSeries Access ODBC Driver", referring to dll CWBODBC.DLL

Here is a screen shot of the setting that I think should be resolving this issue: enter image description here

1
It is gobbledegook for Unicode. 12 chars is a bit much for int32, try reading it as a string first and write a bit of code that uses int.TryParse() to see where it falls over.Hans Passant
I think the underlying problem is that the DB2 driver is not reporting the database types correctly, which leads me to think that tweaking the driver settings should fix it. My solution needs to know the type it is reading, not guess it, because I worry I would get inconsistent results.Daniel Williams
The problem you documented was an overflow exception. It is raised during numerical operations so there's at least a string to number conversion being performed. What doesn't sound good is a column with 12 chars, an int only needs 11 at most. Occam's razor says this the cause of your problem, a column filled with 11 or 12 digits for example. You find it by making the conversion yourself so you can trap the exception and see the record that causes the problem.Hans Passant

1 Answers

1
votes

It turns out that the setting shown above "Convert binary data (CCSID 65535) to text" is the correct setting. The issue is that this only works properly in my case when I use the 32-bit driver. So awkward as it is, for now we just be setting our apps to 32-bit until we solve the issue. But at least we have a workaround and the urgency is diminished.