Using datatable for application settings

jswota

Well-known member
Joined
Feb 23, 2009
Messages
49
Programming Experience
Beginner
Hi,

I'm just looking for some feedback here.

I often create tables to store my application options. The table columns are given the option name and there will only be a single row in the table at all times. I'm just wondering if this is a proper way of handling this.

It just seems a bit cumbersome to get the data. I still have to ensure that the table has rows and then get the first row (Dim m_Row as datarow = table.rows(0)) before finally getting the values. It's no problem getting the data but i was just wondering if there is a more straight forward approach.

FYI - These are global settings that all users have access to. Hence the datatable instead of local application settings.

Thanks,
Joel
 
I would tend to have two columns where one contains the name and the other contains the value. It means storing all settings as text but it also means that you don't need to change the database schema if you add or change a setting.
 
I still have to ensure that the table has rows
Why use a table? just use a row. That should be the job of the constructor: to create and populate a row

You can expose the typed datarow itself via named property and then:

SettingsManager.UISettings.Width

SettingsManager = your class that holds the row
UISettings = a property that references/returns the row
Width = a column of the row

These are global settings that all users have access to. Hence the datatable instead of local application settings.

But Applications have application settings that apply to all users on the machine. If you're looking for all users across the enterprise, nothing wrong with making it download the settings into the Settings system upon app start..
 
Back
Top