When i set up a regular connection, it works, however when i try to use nhibernate, hibernate.cfg.xml, i m getting the following error.
Message="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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)" Source=".Net SqlClient Data Provider"
What would be the reason for this and how can i resolve it ?
I doubt that it s a network or sql server configuration error.
<?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=(ServerName\DEV_ENV);Initial Catalog=dbName;User Id=SA;Password=PASS</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
</session-factory>
</hibernate-configuration>
Try to connect to the server with the same connection string, but with another data access technology, for example pure ADO.NET.
If that fails as well, then it's not a NHibernate problem.
Maybe your connection string or some SQL server settings are not correct, as indicated in the error message:
"Verify that the instance name is correct and that SQL Server is configured to allow remote connections."
Is your connection string correct?
http://www.connectionstrings.com/sql-server-2005
This is the format i have used for over a dozen applications for SQL SERVER 2005/2008
data source=COMPUTERNAME;User Id=USERNAME;Password=PASSWORD;database=DATABASENAME
or if you require an instance name
data source=COMPUTERNAME\SERVERINSTANCE;User Id=USERNAME;Password=PASSWORD;database=DATABASENAME
replace the placeholders in capital letters.
Also ensure that you have set up sql-server to allow connections for Sql Server Authentication
and not only Windows Authentication
.
Check your firewall as well
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With