Where and when should i store and instantiate a ConnectionString (got from web.config) object to be used in an ASP.NET WebApp UI layer, to be passed be passed through Business Layer and Data Access Layer (all layers are different projects/dll).
I know out to create it, and access, i’m just wondering which is the best practice, a Global.asax Property ConnectionString ? Instantiated when (Application_Start, Session_Start)? A Session item?
Thanks for reading, please shout your opinion!
Let your DAL read your connectionstring from your UI web.config. Your presentation layer and business layer do not need to know your database connection string and should not be passed through between layers. So you can initialize it in DAL or put it in constructor. remember to open and close your connection for every method you call in DAL.