View Single Post
  #1 (permalink)  
Old April 2nd, 2008, 05:17 AM
selvakumar_rama selvakumar_rama is offline
Registered User
Join Date: Apr 2008
Location: , , India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to selvakumar_rama
Default fetch data from IBM DB2 using C#

Hi all,
We have a requirment to develop windows based application using C# 2.0 and IBM DB2.
For connecting to DB2, I am refering IBM.Data.DB2.dll in my application. During run time it raise exception in connection declaration.
I have DB2 Client in my local machine, and it is connecting to server also. But through appliaction it raise exception.
I got IBM.Data.DB2.dll from server machine. I refered this dll into my application. I am attaching my code snippet here.

DB2Connection Con = new DB2Connection("Server=myserver; Database=dbname; UID=Db2admin; PWD=password;");
DB2Command cmd = new DB2Command();
cmd.CommandText = "Select * from Reports";
cmd.Connection = Con;
cmd.CommandTimeout = 60;
DB2DataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection) ;

Exception is raising in connection string line itself. Please tell me why this exception is raising.
Followig are the Exception message.

************************************************** *******************
System.TypeInitializationException: The type initializer for 'IBM.Data.DB2.DB2Connection' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'db2app.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

   at IBM.Data.DB2.v.nmpTraceOn()
   at IBM.Data.DB2.v.e()
   at IBM.Data.DB2.DB2ConnPool.d()
   at IBM.Data.DB2.DB2ConnPool..ctor()
   at IBM.Data.DB2.DB2Connection..cctor()
   --- End of inner exception stack trace ---
   at IBM.Data.DB2.DB2Connection..ctor(String connectionString)
   at TestWebServiceConnection.Form1.ApplicationFormInde xReport() in D:\Selvakumar\VS Application\TestWebServiceConnection\TestWebServic eConnection\Form1.cs:line 396

************************************************** *******************

Selvakumar R
Reply With Quote