-->
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.  [ 1 post ] 
Author Message
 Post subject: ABC.cfg.xml Vs web.config -- Multiple config files
PostPosted: Tue Jul 05, 2005 4:56 am 
Regular
Regular

Joined: Mon May 30, 2005 11:20 pm
Posts: 66
Hi, ... one ... big question in regards to configuration files. In our application, database settings is currently loaded from web.config:

In web.config:

<?xml version="1.0" encoding="utf-8" ?>
Code:
<configuration>

  <configSections>
      <sectionGroup name="settings">
          <section name="dbsettings" type="application.utilities.settings.DBSettingsHandler, Utility" />
          ... other stuff ...
      </sectionGroup>
     
       ... other stuff ..
  </configSections>

[b]*** Custom configuration section (Database settings):[/b]
<dbsettings db_ip="localhost" db_port="1433" db_user="ATHKAPPUSER" domain="ATFE" db_password="interim" db_initcat="Security" db_provider="MICROSOFTSQL" />
    ... the rest of it ...
</configuration>


During application start up, database setting is loaded from custom config section as follows:
Code:
dbConfig = CType(_webctx.GetConfig("settings/dbsettings"), DBSettings)
conn_str = dbConfig.ConnectionString
oConn = ConnFactory.CreateConn(conn_str)
... the rest of it ...


With NHibernate, database settings is loaded from its own configuration file - for example, ABC.cfg.xml, instead of web.config:

Code:
Dim DbCfgAs New Configuration
Dim factory As ISessionFactory
Dim o_session As ISession
Dim dbCfgFilePath As String

dbCfgFilePath = Request.ServerVariables("APPL_PHYSICAL_PATH") + "bin\ABC.cfg.xml"
DbCfg.Configure(dbCfgFilePath )
DbCfg.AddAssembly("MyAssemblyName")
factory = DbCfg.BuildSessionFactory()
o_session = factory.OpenSession()


Is it possible for me to set NHibernate database configurations using custom configuration sections in web.config instead of using ABC.cfg.xml? Perhaps to do this programmatically so I don't need to have MULTI-CONFIGURATION files?

Thanks in advance.


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

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.