开发者

Saving User Settings in a Database

开发者 https://www.devze.com 2022-12-16 07:58 出处:网络
1) I use Visual Studio 2008 (C#) 2) I want my desktop application to \"remember\" certain settings (preferences) for every user individually.

1) I use Visual Studio 2008 (C#)

2) I want my desktop application to "remember" certain settings (preferences) for every user individually.

3) The application would use its own database of users (logins + passwords), so they have nothing to do with Windows accounts.

How can I accomplish that?

I was thinking of creating a USERSetting table with name/value pair columns and then serializing this information to a USERSetting Class. My settings in itself can开发者_C百科 be a large xml and i was wondering if there is a better solution.

Any sample code would be helpful.


Putting it on the server with the rest of the data is your best option. That way, the data gets backed up regularly, and if someone gets a new computer, they do not lose their settings.

A name value pair is easy enough to start with, but in terms of database design, it is not considered a good practice. A normalized data structure would be my choice.

You can put the settings in an XML structure and put that into the database if you think that makes it any easier on you.


can you use the built-in UserSettings classes? They have user-specific settings and application-wide settings.


A number of simplifications you can do here.

If you're using SQL Server, it supports XML natively - you can store your settings XML directly to and from the database. This would allow you to serialize/deserialize your XML without having to do any manual property translation.

Look at using a Custom Settings Provider to easily handle moving your settings back and forth.

0

精彩评论

暂无评论...
验证码 换一张
取 消