My professor provided and example of nHibernate and asked us to run it and see how it works and then use nHibernate with our previous assignment.
Unfortunately i havent been able to my sql server 2005 instance. The error i get is an NHibernate.ADOException, "cannot open connection" and it says that the inner exception,
Quote:
{"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)"}
I initially thought it might have been the network error, but even though i disabled the firewall it still wasnt connecting.
I also changed the settings in my SQL instance to allow for remote connections through TCP/IP and named pipes.
I did use ODBC to test the connection and it worked fine. The following is the hibernate.cfg.xml file that the professor provided.
Code:
<?xml version="1.0" encoding="utf-8" ?>
<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=xxxx-PC\SQLEXPRESS DATABASE=nHibernateExample; Trusted_Connection=Yes;Integrated Security=True;</property>
<property name="connection.isolation">ReadCommitted</property>
<property name="default_schema">nHibernateExample.dbo</property>
<property name="show_sql">True</property>
<property name="connection.release_mode">on_close</property>
<mapping assembly="nHibernateExample"/>
</session-factory>
</hibernate-configuration>
I was hoping someone could help me by either
1)telling me what you think i might be doing wrong or pointing me in the right direction,
2) I thought i would use the DSN to connect instead of this way and when i tested it by writing a simple connection class it worked. So is there any way i can do that here. When i tried it with
Code:
<property name="connection.connection_string">DSN=nHibernateExample</property>
it said that "dsn" is not valid.
Thank you.