Peter Nordberg
asked on
Change catalog for connection string dynamically
Hi,
I have this scenario where I have several organisations using the same application but have different databases. Right now I solve this through having different installations for each organisation. However when I update this gets tedious of course. So I wonder is it possible for me to just alter the database catalog in the connectionstring and use the same application code for all organisations?
My connecdtion string looks like this in web.config:
So, my question can I change the database name (catalog=developmentDB) to another database based on some variable I give it dynamically?
Thanks for help!
Peter
I have this scenario where I have several organisations using the same application but have different databases. Right now I solve this through having different installations for each organisation. However when I update this gets tedious of course. So I wonder is it possible for me to just alter the database catalog in the connectionstring and use the same application code for all organisations?
My connecdtion string looks like this in web.config:
<connectionStrings>
<!--Test-->
<!--DEFAULT(Peter) CONNECTION-->
<add name="connDB" connectionString=" Data Source=.\SQLEXPRESS;Initial Catalog=developmentDB;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
So, my question can I change the database name (catalog=developmentDB) to another database based on some variable I give it dynamically?
Thanks for help!
Peter
Yes you can change the database name dynamically as long as the other information in the connection string is correct.
ASKER
How?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi and thanks for answers,
I will test both approaches and come back.
Peter
I will test both approaches and come back.
Peter
Two working solutions posted.