Recommendation for handling dynamic connection strings

Recommendation for handling dynamic connection strings

Old forum URL:

CraigJ posted on Monday, July 29, 2013

Hi.  In the application we are building the connection string to the database will vary based on the project selected by the user from a dropdown.  The schema of the database will be the same for each, but the database name and possibly the server can very based on this selection.  Is there a recommended approach to dealing with this scenario within CSLA 4.0?  At first glance it seems like a code mod to AdoHelper is in order (and to the template to avoid that getting overwritten), but I wanted to see if there is a better way.   Any help is appreciated!

JonnyBee replied on Tuesday, July 30, 2013

There should be overloads that allow you to specify your own connection string.

How you handle the list of databases/connectionstrings is entirely up to your application. 

CraigJ replied on Wednesday, August 07, 2013

Thanks.  I found a prior post from Rocky that helped me with this.


This suggests to use the CSLA.ApplicationContext.ClientContext to keep track of the connection string.  I modified the ADOHelper class to look to that collection for the proper connection string instead of the config file.

Copyright (c) Marimer LLC