title: Connect to IBM DB2 with .Net using only .dll reference
body: <p>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 <strong>IBM.Data.DB2.iSeries.dll</strong>, 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 <strong>IBM.Data.DB2.dll</strong> also requires you to install software before it will work according to this over stackoverflow post: <a href="https://stackoverflow.com/questions/402484/ibm-data-db2">IBM.Data.DB2</a></p>
  
  <p>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?</p>
  
  <p>I know you can do this with Java and the JT Open toolbox (<a href="http://jt400.sourceforge.net/" rel="noreferrer">http://jt400.sourceforge.net/</a>). Why can't you do this with .Net?</p>
  
  <p>Here is a BASIC example of how we currently use the IBM.Data.DB2.iSeries.dll.</p>
  
  <pre><code>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) { }
  }
  </code></pre>
  
  <p>Thanks for your time,
  welzie</p>