-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Connection String Property
PostPosted: Tue Aug 04, 2009 7:01 pm 
Newbie

Joined: Tue Aug 04, 2009 6:53 pm
Posts: 1
Greetings all!

I'm currently working on an ASP.Net 1.1 project and using the 1.0.2 version of nHibernate. I'm running into an issue with the connection string property for SQL Server 2005. I have the following section defined in my web.config file.

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<mapping assembly="<Assembly.Name>" />
</session-factory>
</hibernate-configuration>

I have the database connection string defined in another file and am loading it into my data provider via the code behind. Problem is, the site runs fine on my local box, but when I try to run the site on our test server, I get the following error message: Could not find connection string setting (set hibernate.connection.connection_string or hibernate.connection.connection_string_name property).

I've verified that the connection string is being read correctly on the server and is loaded into the data providers, but nHibernate keeps wanting to look at the property connection.connection_string in the web.config. Is there something I can do to stop nHibernate from looking for this property? What am I doing wrong? Also, adding the connection string at the session-factory level in the web.config is a no go; I have to read it from the "other" file.

Thanks,
ExitusLSU


Top
 Profile  
 
 Post subject: Re: Connection String Property
PostPosted: Wed Aug 05, 2009 2:13 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Afaik, there's no way around supplying the connection string or the name if the string is configured elsewhere in the config file. You can set it manually in the code with something like this:

properties["hibernate.connection.connection_string"] = ...;
cfg.SetProperties( properties );
...
cfg.BuildSessionFactory();

_________________
--Wolfgang


Top
 Profile  
 
 Post subject: Re: Connection String Property
PostPosted: Fri Aug 07, 2009 4:16 pm 
Newbie

Joined: Fri Aug 07, 2009 3:36 pm
Posts: 3
Location: Brazil
One other way to do this is putting this in your

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.connection_string_name">myConnectionString</property>
<mapping assembly="<Assembly.Name>" />
</session-factory>
</hibernate-configuration>

Where
myConnectionString: The name of your ConnectionString property

I hope it helps
Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.