16

I would like to connect to a DB2 database, specifically an iSeries version, using .Net and C# by referencing a .dll and NOT installing any software on the server. Currently we use the IBM.Data.DB2.iSeries.dll, which is installed as part of iSeries access for windows. I don't want to have to install all of that. But apparently I don't have an option because the other provider IBM.Data.DB2.dll also requires you to install software before it will work according to this over stackoverflow post: IBM.Data.DB2

Is there anyway to connect from .Net c# code to DB2 by simply referencing a .dll in your code and NOT installing other software on the server?

I know you can do this with Java and the JT Open toolbox (http://jt400.sourceforge.net/). Why can't you do this with .Net?

Here is a BASIC example of how we currently use the IBM.Data.DB2.iSeries.dll.

String sql = "SELECT 1 FROM SCHEMAX.TABLEX";
System.Data.IDbConnection connection = null;
IDataReader reader = null;
try
{
connection = new iDB2Connection(ConfigurationManager.ConnectionStrings.ConnectionString);
connection.Open();
IDbCommand command = connection.CreateCommand();
command.CommandType = CommandType.Text;
command.CommandText = sql;
reader = command.ExecuteReader();
}
finally
{
try { reader.Close(); } catch (Exception ex) { }
try { connection.Close(); }catch (Exception ex) { }
}

Thanks for your time, welzie

Community
  • 1
  • 1
Blake Mills
  • 824
  • 2
  • 9
  • 15
  • You don't need to install additional software on the server, it comes preinstalled with the OS. Oh, you mean the client =P – ASalazar Jul 29 '10 at 00:25

1 Answers1

10

My question was answered in an IBM forum. Here are the answers.

https://www.ibm.com/developerworks/community/forums/html/threadTopic?id=77777777-0000-0000-0000-000014491597

Answer1: Hi Welzie, While I am not familiar with the JT Open product per say, it is most likely based on a Type 4 JDBC driver, which is a Java only driver on the client side ( as opposed to older Type 2 JDBC driver which required a non-Java component on the client ). Being a Java only driver, allows JT Open to do what you're describing. The .NET driver however, has a much more complicated dependency structure, and as such, requires multiple DLLs to be layed down on the client, both managed and un-managed. Moreover, connectivity to an iSeries server would also require a DB2 Connect licence to be available on the client. Therefore, the minimal client install that is required to support .NET connectivity to a DB2 server is the IBM Data Server Driver ( which is about 40 MB installed ). IBM Data Server Driver is a freely distributred client package that can be downloaded from IBM website. However, as I stated above, to connect to an iSeries server, you would need a DB2 Connect licence as well.

Regards, Alex

Answer2: The IBM.Data.DB2.iSeries.dll provider requires many other parts of the IBM i Access for Windows product, for example to handle the TCP/IP communications stack, security/logon handling, CCSID conversions, etc. It cannot be copied or installed as a standalone dll.

Subbu
  • 2,130
  • 1
  • 19
  • 28
Blake Mills
  • 824
  • 2
  • 9
  • 15
  • 7
    It's the answer I expected...but very poor these days for IBM to package this way. – BlueChippy Sep 24 '12 at 09:44
  • 2
    I know. We have the same issues. It's better if you can avoid ever dealing with IBM, but sometimes you have no choice, and it's a shame IBM isn't competent enough to do this right, yet. You can try one of the other DB2 driver products like Progress DataDirect, but they are expensive. – Andrew Jan 10 '13 at 04:10
  • 2
    @BlueChippy : If you think it's poor of IBM to do it that way, you must be absolutely livid at how others such as Microsoft do it. Try doing the same in the opposite direction. – user2338816 Apr 02 '14 at 12:02
  • 2
    @user2338816 a few years later, .NET Core / SQL Client is fully open source and cross platform, while I still need to install a bunch of IBM crud on my server just to connect to a database. – Tobias J Mar 07 '17 at 16:30
  • Open-source is okay, but it's still significantly more difficult to compile/debug it to get connectivity from IBM i to MS SQL Server than simply to install/configure the IBM components to access DB2 for i from a Windows system. And JDBC (JTOpen) for DB2 for i is also open source and cross platform; works fine on Windows. – user2338816 Mar 21 '17 at 01:40