Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2008

    Red face Unanswered: accessing db2 database in C#

    I am developing windows application using c# 2.0 and DB2. I need to fetch data from DB2, I used to IBM.Data.DB2.dll in my application. DB2 is installed in server machine. My machine doesn't have client DB2. I refer IBM.Data.DB2.dll into my application via <add reference>, I got this dll from server.
    Code snippet:
    DB2Connection Con = new DB2Connection("Server=servermachinename; Database=databasename; userid=Db2admin; password=password;"); (*)
    DB2Command cmd = new DB2Command();
    cmd.CommandText = "Select * from Reports";
    cmd.Connection = Con;
    cmd.CommandTimeout = 60;
    DB2DataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection) ;
    But when I am executing application, exception is raising, , Exception is rasing in "Con" declaration area(*).
    following are the exception...
    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 397

    please help me, it is very urgent requirment...


  2. #2
    Join Date
    Jun 2006
    is this possible without db2 installed ? java type 4 connection is possible, but c# I think needs db2
    Best Regards, Guy Przytula
    DB2 UDB LUW certified V6/7/8

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts