Monday, March 19, 2012

IBM DB2: using db2 providers for .NET

I was creating a tool to automate test data creation on db2 database, at the beginning I faced lot’ s of issues to be able to use the IBM DB2 .NET drivers. I have 64 bit OS, when I installed 32 bit client, can be downloaded from here, using the IBM.Data.DB2 was giving initialization errors, even if the target for my tool is x86, it was giving problems

errors I was getting:

SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7, tokens 9.5.0.DEF.2, SOFTWARE\IBM\DB2\InstalledCopies

I then removed the 32  bit version and installed the 64 bit version, can be downloaded from here , this also was giving errors since the target is x86, I guess it was looking for the 32 bit DB2 dlls.

error I was getting

Could not load file or assembly 'IBM.Data.DB2, Version=9.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Finally, I kept both the the 32 bit and the 64 bit, this worked perfectly, and set the target to x86, when I deployed my application to my colleagues having them installed 32 bit IBM Data Server Driver Package on their 32 bit operating systems, it worked perfectly.