IBM.Data.DB2.Core setup procedure


I want to connect to a DB2 database on an IBM i 7.2 server from a Windows client machine using .NET Core 3.1. I installed IBM.Data.DB2.Core via NuGet, but it always throws this cryptic exception:

  Message=External component has thrown an exception.
   at IBM.Data.DB2.Core.DB2ConnPool.Open(DB2Connection connection, String& szConnectionString, DB2ConnSettings& ppSettings, Object& ppConn)
   at IBM.Data.DB2.Core.DB2Connection.Open()
   at Dapper.SqlMapper.<QueryImpl>d__140`1.MoveNext() in /_/Dapper/SqlMapper.cs:line 1079
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Dapper.SqlMapper.Query[T](IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable`1 commandTimeout, Nullable`1 commandType) in /_/Dapper/SqlMapper.cs:line 721
   at Dapper.SqlMapper.Query(IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable`1 commandTimeout, Nullable`1 commandType) in /_/Dapper/SqlMapper.cs:line 648
   at SqlPerformanceTesting.Program.<Main>d__0.MoveNext() in C:\Users\mmarchese\Desktop\SqlPerformanceTesting\SqlPerformanceTesting\Program.cs:line 54

I think I need to install different drivers/software on my Windows client machine first. Right now, I have "IBM I Access Client Solutions" installed, but maybe I need something else instead such as "IBM Data Server Drivers?" And that requires a license, it seems? Do I also need to install something on the IBM server to go with it? Can someone spell it out for me or point me to a good guide? I haven't been able to find much myself. Like, "Here are the general steps:"

  1. Install software A on Windows client
  2. Install software B on IBM i server
  3. Install IBM.Data.DB2.Core on Windows client
  4. Do procedure C to configure Windows client
  5. Do procedure D to configure IBM server


If I specify a bad connection string, I get a different error. Since IBM.Data.DB2.Core includes a class for building valid connection strings, I assume my connection string is ok:

var connStringBld = new DB2ConnectionStringBuilder()
    Database = "myDb",
    UserID = "myUser",
    Password = "myPassword",
    Server = "myIp"
// Database=myDb;User ID=myUser;Password=myPassword;Server=myIp
asked on Stack Overflow Jul 13, 2020 by MarredCheese • edited Jul 13, 2020 by MarredCheese

1 Answer


I had the same problem but I only follow the next steps:

  • Install IBM.Data.DB2.Core (is ONLY for windows, if using in Linux, you must install IBM.Data.DB2.Core-lnx instead. Also installed cause I run it into Docker container).

  • Paste the licences files (of Windows) in my project located at {MyProject}/License folder. The licences are db2.consv.lic and db2ese.lic files

  • Also check that when I use the Nuget, a linked folder named "clidriver" is attached in the root project. I also verified that the location %userprofile%\.nuget\packages\\\build\clidriver\license had the licence files.

  • Define DI in Startup.cs using:

    services.AddDbContext<Db2Context>(options =>
        options.UseDb2(connection, si =>
            si.SetServerInfo(IBMDBServerType.AS400, IBMDBServerVersion.AS400_07_02));

And that's all I've done. Model the entities and use LINQ as well.

answered on Stack Overflow Jul 13, 2020 by Ilich Morales • edited Jul 15, 2020 by MarredCheese

User contributions licensed under CC BY-SA 3.0