It's working for the 64-bit version. Unfortunately, it's not working correctly for the 32-bit version. The problem is the last parameter of "SQLGetData". For the 32-bit version this is a pointer to a 32-bit signed integer (SQLLEN). This means, the integer overflows for large data >2 GB. I suggest to saturate the value for the 32-bit version and return 0x7fffffff in case the real value is bigger than that. Most applications just check if it's bigger than the provided buffer size and for that returning 0x7fffffff works fine. What do you think about it?