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:
<?xml version="1.0" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">Server=(local);Initial Catalog=dbname;User Id=user;Password=********</property>
</session-factory>
</hibernate-configuration>
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:
Data Source=uatserver\db01,1433;
Initial Catalog=dbname;
User ID=dbuser;
Password=userpassword
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.
<property name="connection.connection_string">
Server=tcp:(uatserver\db01),1433;
Initial Catalog=dbname;
User ID=dbuser;
Password=userpassword</property>
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.)
<property name="connection.connection_string">
Server=(uatserver\db01),1433;
Initial Catalog=dbname;
User ID=dbuser;
Password=userpassword</property>
<property name="connection.connection_string">
Server=uatserver\db01,1433;
Initial Catalog=dbname;
User ID=dbuser;
Password=userpassword</property>
<property name="connection.connection_string">
Server=(uatserver\db01, 1433);
Initial Catalog=dbname;
User ID=dbuser;
Password=userpassword</property>
This is the the last line in the log:
[27 Jul 2009 18:27] NHibernate.Connection.DriverConnectionProvider
[DEBUG] Obtaining IDbConnection from Driver