[Mono-list] IBM.Data.DB2

javaid.rajmohamed@3web.net javaid.rajmohamed@3web.net
Thu, 24 Jun 2004 13:49:11 -0600


Hi 
Trying to connect to DB2 v8.1.5 with beta3 of mono. I connect successfully 
using odbc.

Running win xp pro(home) and w2k pro(work) and it appears i'm doing something 
wrong.

see below for error message and c# code:

C:\>mcs hack1.cs -r System.Data.dll -r IBM.Data.DB2.dll
Compilation succeeded

C:\>mono hack1.exe

Unhandled Exception: System.DllNotFoundException: db2_36
in <0x00050> (wrapper managed-to-native) StaticWrapper36:SQLAllocHandle (int16,i
ntptr,intptr&)
in <0x00040> IBM.Data.DB2.DB2CLIWrapper:SQLAllocHandle (int16,intptr,intptr&)
in <0x0005f> IBM.Data.DB2.DB2CLIWrapper:Initialize (intptr&)
in <0x00057> IBM.Data.DB2.DB2Environment:.ctor ()
in <0x00053> IBM.Data.DB2.DB2Environment:get_Instance ()
in <0x00009> IBM.Data.DB2.DB2ConnectionPool:FindConnectionPool (string)
in <0x0001b> IBM.Data.DB2.DB2ConnectionSettings:GetConnectionSettings (string)
in <0x00048> IBM.Data.DB2.DB2Connection:SetConnectionString (string)
in <0x00058> (wrapper remoting-invoke-with-check) IBM.Data.DB2.DB2Connection:Set
ConnectionString (string)
in <0x00025> IBM.Data.DB2.DB2Connection:.ctor (string)
in <0x00058> (wrapper remoting-invoke-with-check) IBM.Data.DB2.DB2Connection:.ct
or (string)
in <0x00056> Test:Main (string[])


the code:


using System;
 using System.Data;
 using IBM.Data.DB2;
 
 public class Test 
 {
    public static void Main(string[] args)
    {
       string connectionString = "Database=SAMPLE;User 
ID=db2admin;Password=db2admin;Server=myserver"; 


       IDbConnection dbcon;
       dbcon = new DB2Connection(connectionString);
       dbcon.Open();
       IDbCommand dbcmd = dbcon.CreateCommand();
       string sql = 
           "SELECT fname, lname " +
           "FROM employee";
       dbcmd.CommandText = sql;
       IDataReader reader = dbcmd.ExecuteReader();
       while(reader.Read()) {
            string FirstName = (string) reader["fname"];
            string LastName = (string) reader["lname"];
            Console.WriteLine("Name: " + 
                 FirstName + " " + LastName);
       }
       // clean up
       reader.Close();
       reader = null;
       dbcmd.Dispose();
       dbcmd = null;
       dbcon.Close();
       dbcon = null;
    }
 }


-------------------------------------------------
This mail sent with 3webmail http://www.3web.com