where should i write SQL connection string .....wcfservice library's app.config / wcf service's web.config ....? RRS feed

  • Question

  • hi...

    I have created wcf service library project and written SQL connection string in the app.config ....

    then I have reference it in the WCF service as Dll....

    and then i call the service in my client applicaion .... it works fine on the local computer but now the problem is when if I need to chang the SQL connection string...how can i do this ...

    what is the ideal place to write connection string .....?

    so that whenever i need to change connection string I can change it without making chang in the wcf library project witout re-compile,witout re-reference it in the service ...    
    Monday, August 6, 2012 8:55 AM


  • Hi Parthiv,

    If you are looking to place the connection string in a config file, you have to put it in the config file of the application that is eventually going to cause a connection to the database. So in your case the connection string would need to be in the config file of the application hosting your WCF service. In case your service is hosted by IIS or any other web server, then place the connection string in the web.config file of that project.

    I am not quite sure why you have created a WCF service library project and then referencing it in another WCF service project. 


    Nauzad Kapadia.

    • Proposed as answer by Bogdan Verbenets Monday, August 6, 2012 12:37 PM
    • Marked as answer by LeoTang Monday, August 13, 2012 3:11 AM
    Monday, August 6, 2012 9:27 AM