views:

60

answers:

2
+1  Q: 

Is it possible?

Hi

We are thinking of moving some of the 'hard coded' settings out of our windows forms application and storing them in the sql database in a table called App_Settings. The reason for this is we have values currently hard coded into appsettings and app.config which can change over time, and it is much easier and faster to update the values in a database table than it is to update, build and deploy the app over three servers.

Please can someone advise on this, and also how can we load the settings into the app and then have them readily available in any class?

Cheers Richard

+2  A: 

Have a look at this similar thread: http://stackoverflow.com/questions/681008/resources-app-config-or-database-where-is-the-best-place-to-application-strings

When you want to store settings in the database i would implement the class as Singleton or at least as a Class with only static/shared members and a factory method(getAppSettings)which returns that single/static instance. So you could access your settings from everywhere and it is only initialized once.

Tim Schmelter
I would prefer the factory method returning the Singleton myself. The only addition I would make is I'd implement and return an interface from the factory, I find that configuration can be a bit of a pain when it comes to unit testing.
Martin Clarke
A: 

Why don't you use something like YAML to save these settings? It would be easy to create a form to edit and save these settings in a file, instead of a db (which would add more maintainance problems).

Otherwise, I would suggest to use something like NHibernate to use a database, and SQLLite as the db server.

Also, note that if you are updating these settings, I would not say that these are App_Settings, since App_Settings aren't usually modifyable without

Help this helps, Pietro

Beo