Click here to Skip to main content
15,881,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have created Solution Configurations as Development, QA and test using Configuration Manager. I need to connect to respective databases now like if Solution Configuration is Development then connect to Development Database, if QA then connect to QA database and if Test the connect to Test Database. How do i do that in Visual Studio 2019 ?

What code shall i write for that so that it picks the current database settings according to the Databases?

Thanks
Shweta

What I have tried:

I have created Solution Configurations as Development, QA and test using Configuration Manager. I need to connect to respective databases now like if Solution Configuration is Development then connect to Development Database, if QA then connect to QA database and if Test the connect to Test Database.
Posted
Updated 8-Oct-19 4:51am

1 solution

Connecting to databases is handled in code, not the configuration manager.

You need to write code to dynamically determine the environment it's running in, and create the appropriate connection string(s) at run time. There are several ways to identify (or specify) the environment, so I'll leave taht as an exercise for the programmer, especially since we don't know your network topology, nor even if this is a web app or desktop app...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900