Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Share a Connection string between multiple web projects

OK I have two web projects WebProject1 & WebProject2. Both require database connectivity so this is all in a C#.NET project called Common.

Now my question is currently the connection string for both is the same and at the moment it's hard coded into the DB class (In the Common project), but I want to move it out to a config file.

I would really like to have a config file in the Common project with the connection string in which both web projects then use. Is this possible, and if so how?

like image 865
Adam S-Price Avatar asked Nov 02 '09 10:11

Adam S-Price


1 Answers

There's a few ways you could do it:

  1. put common configuration settings in machine.config as shown here
  2. put common configuration settings in a central file and link to that in each projects's app.config as shown here
  3. store the configuration settings in the registry
like image 57
AdaTheDev Avatar answered Sep 28 '22 14:09

AdaTheDev