title: NHibernate connection string: how to specify port number and server\instance?
body: <p>I am replacing my old DAL with NHibernate 2.1. My NHibernate config works on my local dev machine but not on UAT. The UAT database is a cluster setup on a none default port. I am using a standard NHibernate confie file similar to below:</p>
  
  <pre><code>&lt;?xml version="1.0" ?&gt;
  &lt;hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" &gt;
      &lt;session-factory&gt;
          &lt;property name="connection.provider"&gt;NHibernate.Connection.DriverConnectionProvider&lt;/property&gt;
          &lt;property name="dialect"&gt;NHibernate.Dialect.MsSql2005Dialect&lt;/property&gt;
          &lt;property name="connection.driver_class"&gt;NHibernate.Driver.SqlClientDriver&lt;/property&gt;
          &lt;property name="connection.connection_string"&gt;Server=(local);Initial Catalog=dbname;User Id=user;Password=********&lt;/property&gt;
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>I think the problem is the way I specify connection string in NHibernate config file because my existing DAL works with the following connection string:</p>
  
  <pre><code>Data Source=uatserver\db01,1433;
          Initial Catalog=dbname;
          User ID=dbuser;
          Password=userpassword
  </code></pre>
  
  <p>In NHibernate config file I've tried the following combinations, none worked and I was getting different error messages, but mostly they were saying can not connect.</p>
  
  <pre><code>&lt;property name="connection.connection_string"&gt;
          Server=tcp:(uatserver\db01),1433;
          Initial Catalog=dbname;
          User ID=dbuser;
          Password=userpassword&lt;/property&gt;
  </code></pre>
  
  <p>Error: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - No such host is known.)</p>
  
  <pre><code>&lt;property name="connection.connection_string"&gt;
          Server=(uatserver\db01),1433;
          Initial Catalog=dbname;
          User ID=dbuser;
          Password=userpassword&lt;/property&gt;
  
  &lt;property name="connection.connection_string"&gt;
          Server=uatserver\db01,1433;
          Initial Catalog=dbname;
          User ID=dbuser;
          Password=userpassword&lt;/property&gt;
  
  &lt;property name="connection.connection_string"&gt;
          Server=(uatserver\db01, 1433);
          Initial Catalog=dbname;
          User ID=dbuser;
          Password=userpassword&lt;/property&gt;
  </code></pre>
  
  <p>This is the the last line in the log:</p>
  
  <pre><code>[27 Jul 2009 18:27] NHibernate.Connection.DriverConnectionProvider
          [DEBUG] Obtaining IDbConnection from Driver
  </code></pre>