Tutorial :Choosing a Connection String based on kind of request


I used to have a web service through which a client could perform DB operations and a website could read the DB.

Now, due to re-design needs, through the webservice a client can make DB operations. This DB is in workstation A. Through the same webservice, a website retrieves information from DB. This DB is in workstation B.

DB in location A constantly feeds the DB in workstation B, and I need the website to display the information on workstation B.

Is there any way I can have different connection strings on the web.config (both the web service and the website share the same config file) and have the webservice use the corresponding one depending on whether its a client request or a website request ?


Did this using

HttpContext.Current != null? ConnectionStrings["Website"].ConnectionString : ConnectionStrings["Client"].ConnectionString  

and it works perfect

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »