I am aware that one approach to dynamically set the ConnectionString for the Adapter is to set the ConnectionString property of each DataAccessAdapter object being use.
What I'm not clear about is when the DataAccessAdapter object is within a method in a class generated by GenPro.
If I set the ConnectionString property in this generated code, the next time GenPro regenerate the code my modification will be removed and I will need to set the ConnectionString property again (and again) for each DataAccessAdapter object in the generated code.
Is there a better approach?
I know that one way to centralize the ConnectionString is by putting it in the appSettings section of the application config file.
As a matter of fact, I have implemented a solution where we dynamically add a new appSetting entry for GenPro in our application start-up method (using ConfigurationManager, etc.) to have an entry like the following:
<add key="Main.ConnectionString" value="DYNAMICALLY generated..."/>
This approach works. The problem is sometimes the user or the process running our application doesn't have write permission for the config file or the directory where the config file is located.
For this reason, I'm ruling out the use of appSettings.
But if I use the approach above of setting the ConnectionString property of the DataAccessAdapter, what about GenPro generated code that create its own DataAccessAdapter object?
I guess what I am getting at is somekind of static property to set the ConnectionString property of DataAccessAdapter only once w/out having to set for every DataAccessAdapter object instance used.
I know that you can set the 'ConnectionStringKeyName' static property of DataAccessAdapter. But that only specify the key of an appSetting stored in the config file. This is an approach that I want to avoid due to 'write permission' problem and others as I explained above.
Am I missing something here?
Is there a better way to set the ConnectionString of the Adapter object w/out resorting to changing every Adapter object's ConnectionString property and also w/out using the appSettings apporach?
Thanks in advance for your help.