Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Architecture> Multiple Connection strings
 

Pages: 1
Architecture
Multiple Connection strings
Page:1/1 

  Print all messages in this thread  
Poster Message
pilotboba
User



Location:

Joined on:
05-Aug-2005 21:31:38
Posted:
434 posts
# Posted on: 06-Jan-2006 19:14:51.  
Ok,

I am looking for the easiest way to strucuture this. Here is the scenerio.

In our [web] application the user may have several database's set up. The schemas are identical so I can use the same EntityDomain dll. So, for example the customer might have three db's such as:

Production
Test
Training

There is a screen that allows the user to select which db to work in.

The way this works now is that our base DataAccess class has code in it to get the connection string based on the users currently selected db. So, I need to duplicate this code somewhere for LLBLGen.

1. Am I to assume that I must use the Adapter templates to support this scenerio. I think I read somewhere that the utilty.connection string setting wasn't thread safe correct? Where is this stored?

2. So, how can I use a different connection string for each data access adapter? I assume I can specify the connection string rather than having it use a config value. Should I sub-class the data access adapter to get the connection string?

3. How does this affect catalog name? Do I also have to set the catalog name all the time also? Basically this stuff can't be read from the single config file.

Thanks,
BOb
  Top
KristianP
User



Location:

Joined on:
23-Feb-2005 02:34:52
Posted:
32 posts
# Posted on: 06-Jan-2006 21:19:52.  
I created a data access adapter factory component that lets an applicaton use multiple database adapters and as many connection strings as needed. It is also thread safe. Here is a sample of what the xml looks like in the app config. It can also be specified at run time:

Code:
    <sheakley.framework>
        <sheakley.data>
            <dataAccessAdapters>
                <dataAccessAdapter name="WC" commandTimeout='300' type='Sheakley.Evolution.Data.DatabaseSpecific.DataAccessAdapter,Sheakley.Evolution.DataDBSpecific'>
                    <connectionStrings defaultConnectionString="Production" symmetricName='RijndaelManaged'>
                        <connectionString name='Production' catalog='E0x5bpih9SusghXxrUAs/2YsOAtVsqP3jfGQE9haKws=' value="ZczSwRnJzCmU1RbJzahrJo" />
                        <connectionString name='Test' catalog='3CsHY7SHFxE9o1iDwg/gum+Mszc5no=' value="R3xh2IwAmP6RUhoDqAh8IKZCijuxqhp6" />                            
                    </connectionStrings>
                </dataAccessAdapter>
                <dataAccessAdapter name="Corp" commandTimeout='500' type='Sheakley.Evolution.Data.DatabaseSpecific.DataAccessAdapter,Sheakley.Evolution.DataDBSpecific'>
                    <connectionStrings defaultConnectionString="Production" symmetricName='RijndaelManaged'>
                        <connectionString name='Production' catalog='E0x5bpih9SusghXxrUAs/2YsOAtVsqP3jfGQE9haKws=' value="ZczSwRnJzCmU1RbJzahrJo" />
                        <connectionString name='Test' catalog='3CsHY7SHFxE9o1iDwg/gum+Mszc5no=' value="R3xh2IwAmP6RUhoDqAh8IKZCijuxqhp6" />                            
                    </connectionStrings>
                </dataAccessAdapter>
            </dataAccessAdapters>
        </sheakley.data>
    </sheakley.framework>


Here is a few methods that make use:

Code:

Private Const DATA_ACCESS_ADAPTER_CONFIG_KEY = "WC"

Public Shared Sub ChangeEnvironment(ByVal environment As System.String)
DataAccessAdapterManager.GetManager().ChangeDefaultConnectionString(environment)
End Sub

Public Shared Sub ChangeCommandTimeout(ByVal commandTimeout As System.Int32)
DataAccessAdapterManager.GetManager().ChangeDefaultCommandTimeout( _
DATA_ACCESS_ADAPTER_CONFIG_KEY, commandTimeout _
)
End Sub

Public Shared Function GetAvailableEnvironments() As System.String()
Return DataAccessAdapterManager.GetManager().GetAvailableConnectionStringTypes( _
DATA_ACCESS_ADAPTER_CONFIG_KEY _
)
End Function

Public Shared Function GetCurrentEnvironment() As System.String
Return DataAccessAdapterManager.GetManager().GetCurrentConnectionStringType(DATA_ACCESS_ADAPTER_CONFIG_KEY)
End Function

Friend Shared Function CreateDataProvider() As IDataAccessAdapter
Return DataAccessAdapterManager.GetManager().Create(DATA_ACCESS_ADAPTER_CONFIG_KEY)
End Function





If you send me your email, I can shoot you the code. Also, it uses the MS App Block for the encryption, but I should really re-factor the code and use a strategy to handle the encryption, but you can just comment that portion out if need b.


  Top
Skeeterbug
User



Location:
Phoenix, AZ
Joined on:
21-May-2004 19:18:48
Posted:
165 posts
# Posted on: 07-Jan-2006 01:05:33.  
pilotboba wrote:
Ok,

I am looking for the easiest way to strucuture this. Here is the scenerio.

In our [web] application the user may have several database's set up. The schemas are identical so I can use the same EntityDomain dll. So, for example the customer might have three db's such as:

Production
Test
Training

There is a screen that allows the user to select which db to work in.

The way this works now is that our base DataAccess class has code in it to get the connection string based on the users currently selected db. So, I need to duplicate this code somewhere for LLBLGen.

1. Am I to assume that I must use the Adapter templates to support this scenerio. I think I read somewhere that the utilty.connection string setting wasn't thread safe correct? Where is this stored?

2. So, how can I use a different connection string for each data access adapter? I assume I can specify the connection string rather than having it use a config value. Should I sub-class the data access adapter to get the connection string?

3. How does this affect catalog name? Do I also have to set the catalog name all the time also? Basically this stuff can't be read from the single config file.

Thanks,
BOb


The Adapter constructor takes a connection string if you want. You should be able to find plenty of creative ways to play with that. Confused

In my scenerio, I would uncomment sections of my web.config to swap test/development databases.
-Skeeter  Top
Anthony
User



Location:

Joined on:
04-Oct-2006 05:07:58
Posted:
154 posts
# Posted on: 29-Apr-2009 06:35:29.  
llblgen 2.6,adapter,sql server,vb.net

Have two databases with the sames schema but difference database names on the same server.

want to do some queries on the databases and have been doing this by

Dim oAdapter As New DataAccessAdapter(DBSTring)

where DBSTring is the connectionstring.


This doesn't appear to work...the DAL was created using DBA

When i try to run a query on DBB using the connectrion string for DBB, the queries appears to be still querying DBA!

Please help?


  Top
MTrinder
User



Location:
London by day, Milton Keynes by night.
Joined on:
08-Oct-2008 17:55:47
Posted:
1461 posts
# Posted on: 30-Apr-2009 15:34:47.  
This has been answered on your other thread.

Matt
  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.