Multiple connections to same SQL Server


So far all of my testing has just been against a single database and so using the RemoteDBServer demo has been fine but now I'm starting to look at how I can start using RemoteDB for some of my existing applications as I really like what it looks like RemoteDB is going to let me do however this has now raised another quandary.

Different applications use different databases that are specific to their requirements however I have a common database that contains tables with information that can be and often is used by all applications so I need to make sure that this is always available so I want to make sure that the RemoteDB server application I create includes this connection. Configuring the URL's is simple i.e.

http://localhost:2001/blahblah/App1 for the application
http://localhost:2001/blahblah/CommonDB for the Common database

but where I'm stuck is for the creation of the ADOConnection itself and specifically how to specify the correct ConnectionString to ensure that the "InitialCatalog" is correct, the RemoteDB demo and the documentation configure the modules in different ways but as far as I can see there doesn't appear to be any way to determine which connection string to use except by using some sort of global variable which wouldn't be an issue I'm just checking that this would be the correct way of doing things, that is I would end up with something like:

function TForm1.CreateIDBConnection: IDBConnection;
  Conn : TADOConnection;
  CoInitializeEx(nil, COINIT_MULTITHREADED);
  Conn := TADOConnection.Create(nil);
  if Variable = 'CommonDB' then
    Conn.ConnectionString := CommonDBConnectionString
    else Conn.ConnectionString := ApplicationConnectionString;
  Conn.LoginPrompt := false;
  Result := TDbGoConnectionAdapter.Create(Conn, true);

Am I going in the right direction or am I going the wrong way up a one way street?


That would not be the a good way. For multiple databases, all you have to do is create two TRemoteDBModule, create two IDBConnectionFactory, each one with a different setup.
So something like this (based on the example in the documentation):

CommonModule: TRemoteDBModule;
AppModule: TRemoteDBModule;
Server: THttpSysServer.Create;
Server := THttpSysServer.Create;
CommonModule := TRemoteDBModule.Create('http://localhost:2001blahblah/CommonDB/',
        function: IDBConnection
          Result := CreateNewIDBCommonConnection;

AppModule := TRemoteDBModule.Create('http://localhost:2001blahblah/App1/',
        function: IDBConnection
          Result := CreateNewIDBApp1Connection;


with the CreateNewIDBxxxConnection functions actually having the necessary code for the SQL connections?

Yes, just like that.