Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to set connection string using config file
Message
From
12/09/2008 10:22:56
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
To
12/09/2008 05:01:56
General information
Forum:
ASP.NET
Category:
Databases
Miscellaneous
Thread ID:
01303511
Message ID:
01347055
Views:
24
>>>If you want to switch between different databases, the connectionstring itself is the place for that.
>>>Your tableadapters should always point to the same connectionstring definition of your app.config.
>>>To switch to a different database, just change the connectionstring in your app.config.
>>
>>There has to be a better way if you want to access different databases with the same TableAdapters.
>
>well, what's your definition of "better way" in this case?
>
>If you want to connect to different databases, you will have to change the connectionstring somehow and you will want to change it in one single place only. The config file is that single place and it is very easy to change the connectionstring because its XML (text) only, unless its not encrypted.

Well you could implement a key/ value pair system for your connection strings and switch programatically by selecting the the connection string key you want to use. You would then still use the TableAdapter appropriate for the given database type. It wouldn't be that difficult to do that yourself. Or you could use a framework such as Mere Mortals that does this automatically (cheap plug). :-)
Tim
Timothy Bryan
Previous
Reply
Map
View

Click here to load this message in the networking platform