Last post Nov 09, 2010 02:47 PM by atconway
Nov 09, 2010 03:54 AM|mhbrown|LINK
Sure this is probably a simple problem to resolve but I am a little stuck!
I will explain the my current yet simple architecture of my application(s). At the moment I have my main web application as a separate project. I then reference the CoreBLLDAL (Business Logic and Data Access) Project so that several projects can have access
to the BLL/DAL Project.
Within the CoreBLLDLL Project I use TableAdapters for my DAL.
I have just upgraded to VS2010 and I would like to make use of the Config Transforms, allowing me to have a separate web.config for test and production - however, TableAdapter get the connection string from the Settings.settings file.
How can I change the TableAdapters to get the connection string from the app/web.config file? I read that you can change this within the designer file for the TableAdapters by using ConfigurationManager, however, I tried this but I do not have access to
the ConfigurationManager namespace. I presume this is because the project is a class library and not a web application - I am not too sure.
All help appreciated. Thanks in advance.
Nov 09, 2010 10:50 AM|mhbrown|LINK
Nov 09, 2010 02:47 PM|atconway|LINK
I read that you can change this within the designer file for the TableAdapters by using ConfigurationManager, however, I tried this but I do not have access to the ConfigurationManager namespace. I presume this is because the project is a class library and
not a web application - I am not too sure.
1. I believe in order to do this you have to elevate the 'ConnectionModifier' property of the TableAdapter to Public then modify the code within to pull the value from the .config file you wish. Read the following for some more information on doing this:
Assign connection string to table adapter:
2. Since this is really an implementation detail on using TableAdapter, you might want to try a forum that specializes in these types of controls like the one listed below:
DataSource Controls - SqlDataSource, ObjectDataSource, LinqDataSource Forum: