Whiz
Whiz

Reputation: 21

Saving User Settings in a Database

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 be a large xml and i was wondering if there is a better solution.

Any sample code would be helpful.

Upvotes: 2

Views: 2280

Answers (3)

womp
womp

Reputation: 116977

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.

Upvotes: 0

Muad'Dib
Muad'Dib

Reputation: 29196

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

Upvotes: 0

Raj More
Raj More

Reputation: 48016

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.

Upvotes: 1

Related Questions