c#在数据库中存储用户设置 [英] c# store user settings in database

查看:203
本文介绍了c#在数据库中存储用户设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个简单的方法来存储一个人的用户设置在sql 2000数据库。理想情况下,一个字段中的所有设置,所以我不必每次添加一个设置时都必须编辑表。如果有人有一个例子,我正在考虑串行化设置类的行。

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.

我不想使用内置的.NET用户设置存储在持久存储是工作使用超强的配置文件,所以一旦用户注销设置被清除这是一个痛苦。我发布了要求以前的任何解决方案,但没有得到太多的回应。

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.

推荐答案

VS设计器保持属性设置在 ApplicationSettingsBase 类中。默认情况下,这些属性被序列化/反序列化为每用户XML文件。您可以使用自定义 SettingsProvider 来覆盖此行为。您可以在其中添加数据库功能。只需将 SettingsProvider 属性添加到VS生成的设置类:

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 { 
   ...
}

一个很好的例子是 RegistrySettingsProvider

我用同样的方式回答了另一个类似的问题此处

I answered another similar question the same way here.

这篇关于c#在数据库中存储用户设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆