title: Connection string for Informix for .NET
body: <p>We are using an Informix database, and are connecting to it from .NET sucessfully using ODBC. The connection string we are using is;</p>
  <pre><code>DRIVER={IBM INFORMIX ODBC RIVER};
  UID=username; PWD=password;
  DATABASE=our_database;
  HOST=devsrv01;
  SERVER=devsrv01_tcp;
  SERVICE=ids9tcp2;
  PROTOCOL=onsoctcp;
  CLIENT_LOCALE=en_US.CP1252;
  DB_LOCALE=en_US.819;
  </code></pre>
  <p>We want to change from ODBC and use IBM's SDK and libraries as <a href="http://www.ibm.com/developerworks/data/library/techarticle/dm-0510durity/index.html" rel="nofollow noreferrer">outlined on their site</a>.</p>
  <p>The code we are using is;</p>
  <pre><code>string ConnectionString = &quot;Database=our_database; Server=172.22.0.0:1528; UID=username; Password=password; &quot;;
  
  try
  {                               
      IfxConnection conn = new IfxConnection(ConnectionString);
      conn.Open();
  }
  catch (IfxException ex)
  {}
  </code></pre>
  <p>The conn.Open() throws the exception;</p>
  <p>ERROR [08001] [IBM] SQL30081N  A communication error has been detected. Communication protocol being used: &quot;TCP/IP&quot;.  Communication API being used: &quot;SOCKETS&quot;.  Location where the error was detected: &quot;172.22.0.0&quot;.  Communication function detecting the error: &quot;recv&quot;.  Protocol specific error code(s): &quot;<em>&quot;, &quot;</em>&quot;, &quot;0&quot;.  SQLSTATE=08001</p>
  <p>&quot;Ah ha!&quot; you say. Just put in &quot;<code>PROTOCOL=onsoctcp;</code>&quot; But this makes the <code>IfxConnection(ConnectionString);</code> command throw an <code>ArgumentException</code>. If the connection string contains any invalid <code>&lt;field&gt;=&lt;value&gt;</code> setting it throws this exception. If I put in garbage=junk; in it throws the same ArgumentException which makes me think it doesn't recognise the Protocol (or PRO) field.</p>
  <p>(FYI) 172.22.0.0 is the IP for devsrv01 and does not end 0.0.</p>