Steve Eggering
Steve Eggering

Reputation: 808

Calling AS400 DB from .Net Core

I have a .Net Core WebAPI, and I have the IBM.Data.DB2.Core package installed. When I try to call the DB2Connection constructor with a connection string, I'm getting the following error.

Unable to load DLL 'db2app64.dll': The specified module could not be found.

Is this something that should be included with the DB2.Core package? Is there a better way to call an AS400 DB from .Net Core?

My code looks like this:

DB2Connection conn = new DB2Connection("Server=as400.example.com;Database=CLIENTS01;UID=user1;PWD=password1;");

Upvotes: 2

Views: 6348

Answers (2)

bhamby
bhamby

Reputation: 15469

If you are using the .NET Core package, you will have to include the path to the driver (which is included in the NuGet package) in your PATH variable.

Here's the relevant part of the FAQ on the NuGet package on Developer Works:

Q: Do I need to do any additional configuration for using this configuration.

 Yes,  On Windows :
   if C:\Users\<USERNAME>\ is the NuGet package folder then
   add to the path:  C:\Users\<USERNAME>\.nuget\packages\IBM.Data.DB2.Core\1.0.0.100\build\clidriver\bin

 and On Linux:
    append $HOME/.nuget/packages/IBM.Data.DB2.Core-lnx/1.0.0.100/build/clidriver/lib
    to the LD_LIBRARY_PATH.

I've found the easiest way to get it set is to set the PATH variable in your project settings. Check out this blog post about some different ways you can do that.

In fact, this other Developer Works page says:

Instructions for downloading and using the package

The following are the prerequisites for using the package

  • Any other IBM DB Drivers should not be present in the machine.

  • Path/LD_LIBRARY_PATH needs to be updated to include the package driver path.

Upvotes: 6

subkonstrukt
subkonstrukt

Reputation: 446

you need to install the IBM Data Server Driver Package wich you can get over there

http://www-01.ibm.com/support/docview.wss?uid=swg24038920

it includes the dependencies you are missing

Upvotes: 0

Related Questions