NEWBIE: How to programatically alter a ConnectionString?
Posted on 2006-06-01
I'm a total newbie at C# and VS2005, coming from Java world...
I have made my first useful in-house app, which uses a DataGridView to allow access to a particular table. Next, I'd like give the user the ability to point to the "same" table in a different database (on the same box). (We typically have multiple versions of the "same" db...)
This can be crude and simple. It would be OK for now to hard-code a drop-down list, for instance, and allow the user to select "Database1, Database2...". The app would start up as now, and default to Database1.
I know this probably involves altering the ConnectionString. But:
1. It's in XML, which I haven't worked with much. Would I need to programatically alter that string?
2. And I don't understand the mechanics involved. Assuming I altered that string, then what do I do? Would I need to restart basically the whole app?
3. I'm assuming I can switch databases at run-time, right? (Given that the table definitions themselves are identical)
Any general help would be appreciated !