views:

37

answers:

1

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: http://stackoverflow.com/questions/402484/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

A: 

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

https://www.ibm.com/developerworks/forums/thread.jspa?threadID=335816

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.

welzie