Unable to load DLL 'db2locale.dll' (Exception from HRESULT: 0x8007007E) [DB2 case, not the Informix one]

1

I am using this piece of code to access the IBM DB2 server. Here is the code

DB2Command MyDB2Command = null;
            // Use the dsn alias that you defined in db2dsdriver.cfg with the db2cli writecfg command in step 1.
            String MyDb2ConnectionString = "DataSource=192.168.1.3;UserID=CONFISCATED_FOR_OBVIOUS_REASONS;Password=CONFISCATED_FOR_OBVIOUS_REASONS;";
            DB2Connection MyDb2Connection = new DB2Connection(MyDb2ConnectionString);
            MyDb2Connection.Open();
            MyDB2Command = MyDb2Connection.CreateCommand();
            MyDB2Command.CommandText = "SELECT CCUST AS DealerCode, TRIM(CNME) AS DealerName FROM ERPLX831F.RCM WHERE CType = 'DLR' OR CType = 'SHR' AND CREF04 <> '' ORDER BY CCUST";
            Console.WriteLine(MyDB2Command.CommandText);

            DB2DataReader MyDb2DataReader = null;
            MyDb2DataReader = MyDB2Command.ExecuteReader();
            Console.WriteLine("Dealer Code\tDealer Name");
            Console.WriteLine("============================");
            while (MyDb2DataReader.Read())
            {
                for (int i = 0; i <= 1; i++)
                {
                    try
                    {
                        if (MyDb2DataReader.IsDBNull(i))
                        {
                            Console.Write("NULL");
                        }
                        else
                        {
                            Console.Write(MyDb2DataReader.GetString(i));
                        }
                    }
                    catch (Exception e)
                    {
                        Console.Write(e.ToString());
                    }
                    Console.Write("\t");

                }
                Console.WriteLine("");
            }
            MyDb2DataReader.Close();
            MyDB2Command.Dispose();
            MyDb2Connection.Close();

However, it is throwing the following exception

Unhandled Exception: System.DllNotFoundException: Unable to load DLL 'db2locale.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

I am using a 32-bit driver and the CPU type is also configured to be x86 while the OS is Windows 10 64-bit.

This question, although, is about db2locale.dll, yet it is different from the following SO question as that query is related to Informix and mine is related to DB2.

IBM .net driver cannot find db2locale.dll

Please help.

c#
db2

1 Answer

0

Run Developer Command Prompt for VS as administrator and run the following command

gacutil -i "C:\Program Files (x86)\IBM\IBM DATA SERVER DRIVER\bin\netf40\IBM.Data.DB2.dll"
answered on Stack Overflow Oct 17, 2018 by theLuckyOne

User contributions licensed under CC BY-SA 3.0