Tutorial :Is it possible?



Question:

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


Solution:1

Have a look at this similar thread: 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.


Solution:2

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


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »