Altering a connection string when moving a .NET app from Development to Production
So, I can store my connection string in Settings and have something like this:
Data Source=.\SQLEXPRESS; <other stuff...>
it's set up as an application setting which seems to be the right place.
but when it moves to production, I would like an administrator whilst running my application to be able to alter the Data Source to point at their SQL Server where ever that might be, I imagine on their server.
Data Source=<my SQL Server>; <otherstuff...>
but, of course, Application settings cannot be updated by the program...
Or have I missed something fundamental...
Application-scoped settings can be edited by the application, but it's not as straight-forward as user-scoped settings. Also, the user running the application generally must be an administrator, because it requires permission to write to the program folder, which is generally going to be under the Program Files folder. If you really want to go that way then you might check this out:
[.NET 2.0+] Protected Configuration (Encrypting Config Files)
That said, when you add items on the Settings page of the project properties, they are stored in the application's config file. Generally the user would just edit that config file, which is XML, by hand.
I suppose, if the user can edit the config file, then so can my app and I can give the user a pretty interface to do it in too.
thanks for that...