multiple connection string support

Posts   
 
    
derrick
User
Posts: 40
Joined: 14-Jan-2004
# Posted on: 14-Jan-2004 23:04:53   

I need to use different connection strings that are determined at runtime. The docs refer to putting the connection string in the .Config file like <appSettings><add key="Main.ConnectionString" value="something"/></appSettings> which implies only one connection string is supported. I need the ability to create unrelated entities that come from different databases. THoughts?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 15-Jan-2004 10:16:21   

You need multiple databases in the same instance of your application or one database for this instance, another for another instance?

Frans Bouma | Lead developer LLBLGen Pro
derrick
User
Posts: 40
Joined: 14-Jan-2004
# Posted on: 15-Jan-2004 15:47:44   

Both. In order to scale our application we have mutiple databases with the same schema but different data. If UserA asks for MyEntity it might come from databaseA while the same MyEntity would come from databaseB for UserB. We also have the need for different entities to persist in different databases.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 15-Jan-2004 22:07:59   

derrick wrote:

Both. In order to scale our application we have mutiple databases with the same schema but different data. If UserA asks for MyEntity it might come from databaseA while the same MyEntity would come from databaseB for UserB. We also have the need for different entities to persist in different databases.

The Adapter template set (currently in beta, you can download the beta archive from the customer area -> template section) is build for that purpose. The current template set, self servicing, is meant to work with 1 database, as there is no object you can access which controls the persistence.

Adapter's VB.NET templates arrive on saturday I hope (I'm done porting, now I have to weed out the porting issues) and docs and final code next week. The archive comes with an example application you can use to get started with Adapter.

Adapter's DataAccessAdapter object contains a property CatalogNameUsageSetting, which you can set to ForceWrite to overwrite catalog names in entities, or to Clear to use the catalog in the connection string (you can specify a connection string on a per action basis, which is ideal for your situation).

You can get started with the beta, and continue working with that code when the final is released later next week.

Let me know if you run into problems getting started, let me know.

Frans Bouma | Lead developer LLBLGen Pro
derrick
User
Posts: 40
Joined: 14-Jan-2004
# Posted on: 16-Jan-2004 01:51:14   

yes. The Adapter template looks like it will do the trick. thanks for the help.

Posts: 1
Joined: 30-Nov-2007
# Posted on: 30-Nov-2007 00:25:46   

I tried using wha you have mentioned but adatper still read the connection string from its app.config

adapter = new DataAccessAdapter(connectionString);

FYI: I seperated Project for Data layer and I reference these dlls into my application.

If I take the database offline mentioned in - *.DLDBSpecific.AppConfig.Main.ConnectionString it througs me an error about the same but doesnt use the connection string I provide during runtime, Am I missing any other settings?

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 30-Nov-2007 10:15:16   

ConnectionStrings only specify the server to connect to, the catalog name is hard coded. To change the catalogName at runtime, use the following overload of the DataAccessAdapter CTor


public DataAccessAdapter(string connectionString, bool keepConnectionOpen, CatalogNameUsage catalogNameUsageSetting, string catalogNameToUse)

Set the catalogNameUsageSetting to ForceName, and set the catalogNameToUse to the required catalog name.

P.S. Please next time don't hijak old threads.

bikswan
User
Posts: 14
Joined: 20-May-2009
# Posted on: 20-May-2009 18:08:04   

hi,

Is there any way of doing it in self-servicing?

regards,

Bibek

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 21-May-2009 09:16:46   

Please don't use an old thread, rather open a new one, and describe what exactly are you trying to do.

Forum Guidelines: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7722