I have a solution file which includes DAL project,BLL and web project.
my web application is using web.config for connection string and DAL is using app.config and it makes problem for me when I publish the web site. because every time I wanna to change the connection I have to republish the web site.
I was wondering is there any way that app.config or even my datasets in DAL get the connection string from web.config file?
I googled it but i didn't find any good soloutions.
Friend, you can use the connection string specified in the Web.Config itself in the DAL layer. Here
logic to implement it
Hope it helped you. Good luck!
Please Don't forget to click "Mark as Answer" on the post that helped you.
This can be beneficial to other community members reading the thread.
I think you're kind of approaching it wrong. The DAL should have all your DB connection information and you should be referenceing the DAL in the BLL and the BLL from the Presentation layer. There should not be any connection information in the web project if you are indeed using a 3 tier approach.
"Hokey religions and ancient weapons are no match for a good blaster at your side."
where should I put this code?
ConnectionStringSettingsCollection connectionStrings = WebConfigurationManager.ConnectionStrings as ConnectionStringSettingsCollection;
ConnectionStringSettingsCollection : in System.Configuration
WebConfigurationManager : in System.Web.Configuration