Coffeehouse Thread

3 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Why keep ConnectionString in Web Tier

Back to Forum: Coffeehouse
  • User profile image
    pwzeus

    Why keep it in web.config, I can not access it in my business layer (seperate class library). I am using data access block and SQL Helper asks for connection string as input param. I dont wan to supply this everywhere as it is going to be the same through out the application. 

    so where do i store my connection string ? I dont want to pass it though my web layer, why should web layer know anything about data base connections.

       

  • User profile image
    JChung2006

    So don't.  Another place to put it is in a strongly typed Settings class.

    I'm not sure why you can't access it from your class library though. I have no problems using Web.config connection strings from my class libraries.

    Coincidentally, this thread probably should have been posted to TechOff.

  • User profile image
    Kevin Daly

    Consider that you may risk making life complicated for yourself for what considerations that may not add tangible benefit to th project.You can achieve logical separation of tiers without requiring strict physical separation..think of Web.config as providing configuration for the application rather than the web interface - you get the ability to manage your interaction with connection strings via ConfigurationManager (and can have them encrypted transparently to the application) - IMO that's worth more (because it solves real problems) than having the good opinion of the architecture police.I think that if you design your data access llibrary to work against an app.config file local to the project, all you have to do is copy the relevant settings to Web.config when you create your reference to the library (if that's what you do). I haven't tried it lately though so I could be wrong about that.


    I see the Channel 9 language nanny replaced my reference to the late, unlamented and psycho National Socialist Party (which I originally had instead of "police") with its annoying "Wash your mouth out with soap!"-style weasel message. How unutterably lame.

    Anyone would think we were in primary school.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.