Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# store user settings in database

Is there an easy method to store a person's user settings in a sql 2000 database. Ideally all settings in one field so I don't keep having to edit the table every time I add a setting. I am thinking along the lines of serialize a settings class if anyone has an example.

The reason I don't want to use the built in .NET user settings stored in persistent storage is work uses super mandatory profiles so upon a users log off the settings are cleared which is a pain. I posted asking for any solutions to this previously but didn't get much of a response.

like image 227
PeteT Avatar asked Oct 05 '08 02:10

PeteT


1 Answers

The VS designer keeps property settings in the ApplicationSettingsBase class. By default, these properties are serialized/deserialized into a per user XML file. You can override this behavior by using a custom SettingsProvider which is where you can add your database functionality. Just add the SettingsProvider attribute to the VS generated Settings class:

[SettingsProvider(typeof(CustomSettingsProvider))]
internal sealed partial class Settings { 
   ...
}

A good example of this is the RegistrySettingsProvider.

I answered another similar question the same way here.

like image 135
Bob Nadler Avatar answered Sep 30 '22 01:09

Bob Nadler