I have an asp.net site that hosts codes for several different organisations. I would like to be able to form the connection string differently depending on the user that is logged in, since each organisation has their own database, but uses the same asp.net code.
For example a connection string can look like this for Organisation A:
<add name="dbConn" connectionString=" Data Source=.\SQLEXPRESS;Initial Catalog=db1DBLocal;Integrated Security=True" providerName="System.Data.SqlClient" />
And for Organisation B:
<add name="dbConn" connectionString=" Data Source=.\SQLEXPRESS;Initial Catalog=db2DBLocal;Integrated Security=True" providerName="System.Data.SqlClient" />
It's important that the name of the connection is the same but that the catalog can be altered.
Worth mentioning is that I also in the current system has added a class called config.vb. In that class I have put the following code to easily be able to use the connection string in my code behind pages:
Public Shared ReadOnly Property ConnectionString() As String
So if the solution in some way can be compatible with this waqy of working it would be great!
I have two parameters called systemID and one called systemDatabase as profiles in the system and those parameters decides what system and what database the user belongs to.
If someone has a good solution to how I easily can solve this I would be most grateful.
Thanks for help!