Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1103755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:23:07+00:00 2026-05-17T01:23:07+00:00

Scenario: I have an application that pulls data from a SQL database as well

  • 0

Scenario: I have an application that pulls data from a SQL database as well as an Oracle database. I have NHibernate implemented for the SQL side and a co-worker already has a working implementation of the Oracle side (same object different project). I am currently defining a connection string in App.Config and calling this function in Program.cs

 var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["Foo"].ToString();
 var configuration = InPlaceConfigurationSource.Build(DatabaseType.MsSqlServer2000, connectionString);
 ActiveRecordStarter.Initialize(System.Reflection.Assembly.GetExecutingAssembly(), configuration);

Note the project is in C# .Net 3.5

I have read about using DifferentDatabaseScope but when I try that the queries don’t return any results nor can I see anything in the NHib Profiler. No errors pop up just 0 count.

Question: How do I implement multiple connections?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:23:08+00:00Added an answer on May 17, 2026 at 1:23 am

    For future users who come across this problem.
    This article helps http://www.darkside.co.za/archive/2008/01/21/castle-activerecord-connecting-to-multiple-databases.aspx

    To get this to work I had to add these code snippets to my App.config

    <activerecord>
    
    <config>
      <add key="connection.driver_class" 
          value="NHibernate.Driver.OracleClientDriver" />
      <add key="dialect"                 
          value="NHibernate.Dialect.Oracle10gDialect" />
      <add key="connection.provider"            
          value="NHibernate.Connection.DriverConnectionProvider" />
      <add key="connection.connection_string" 
          value="Data Source = 
                  (DESCRIPTION = 
                     (ADDRESS = 
                        (PROTOCOL = TCP)
                        (HOST = SERVERNAME)
                        (PORT = 1521)
                     )
                     (ADDRESS = 
                        (PROTOCOL = TCP)
                        (HOST = SERVERNAME)
                        (PORT = 1521)
                     )
                     (LOAD_BALANCE = yes)
                     (CONNECT_DATA =
                        (SERVER = DEDICATED)
                        (SERVICE_NAME = NAME)
                     )
                  );User Id = ID; Password = PASS;" />
    </config>
    

    And this

        <config type="Sens.SensClass`1, Sens">
          <add key="connection.driver_class" 
             value="NHibernate.Driver.SqlClientDriver" />
          <add key="dialect"                 
             value="NHibernate.Dialect.MsSql2000Dialect" />
          <add key="connection.provider"     
             value="NHibernate.Connection.DriverConnectionProvider" />
          <add key="connection.connection_string" 
             value="Data Source=mntcon016\;Initial Catalog=TEST;Trusted_Connection=True;" />
        </config>
      </activerecord>
    
    
      <configSections>
        <section name="activerecord"
                    type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord" />
        <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
      </configSections>
      <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
        <session-factory>
          <property name="proxyfactory.factory_class"> NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle </property>
        </session-factory>
      </hibernate-configuration>
    

    Then in Program.cs before Application.Run I have

     ActiveRecordStarter.Initialize(
                   ActiveRecordSectionHandler.Instance, types.ToArray());
    

    Where types is a list(function requires an array) of type[]. This list needs to contain every class that will be used with Nhibernate. In my case it contains both the SQL and Oracle classes. As well as this class that is inherited by all my SQL classes

    public abstract class TestClass<T> : ActiveRecordBase<T>
    {
    
    }
    

    To generate my SQL classes I had used a generator and it made them all Serializable which had to be taken off. Also note that you cannot have classes with the same name or you will get an error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario: I have an application (C#) that expects a SQL database and login, which
We have a simple LOB application that: pulls data from EF serves data across
Scenario I have a background worker in my application that runs off and does
The Scenario I have written a Silverlight 3 Application that uses an SQL Server
I have an application that once started will get some initial data from my
I have a mixed application that has data both in a database and in
Here's the scenario - I have a C# application that reads from a COM
I have an application which pulls XAML page paths from a database. I can
I have an application that processes data stored in a number of files from
Scenario: I have a console application that needs to access a network share with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.