PC Review


Reply
Thread Tools Rate Thread

Best way to maintain settings?

 
 
Ronald S. Cook
Guest
Posts: n/a
 
      26th Aug 2006
We have a .NET Win app that runs at 12 different cattle feeding lots. Each
lot runs an isolated instance of our app using its own SQL Server instance.

For overall settings specific to a feedlot, we're maintaining those values
right now in the database. But I'm not sure its the best way to do it. You
see, we have a table "tblFeedlot" with about 20 columns BUT then only one
record in the table.

I thought maybe the table should have just two columns "Name" and "Value" to
and have 20 records, but then the datatype would have to be varchar(100) I
suppose and we'd have to d alot of validating/converting. But maybe this is
the better way to go?

Or do you recommend another way? Would there be some sort of app.config
specific to each feedlot that we stored somewhere?

Thanks,
Ron


 
Reply With Quote
 
 
 
 
Nicholas Paldino [.NET/C# MVP]
Guest
Posts: n/a
 
      27th Aug 2006
Ron,

The app.config file is exactly what you should be doing. You can set
the values you need in the app.config file, and then read them easily.


--
- Nicholas Paldino [.NET/C# MVP]
- (E-Mail Removed)

"Ronald S. Cook" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> We have a .NET Win app that runs at 12 different cattle feeding lots.
> Each lot runs an isolated instance of our app using its own SQL Server
> instance.
>
> For overall settings specific to a feedlot, we're maintaining those values
> right now in the database. But I'm not sure its the best way to do it.
> You see, we have a table "tblFeedlot" with about 20 columns BUT then only
> one record in the table.
>
> I thought maybe the table should have just two columns "Name" and "Value"
> to and have 20 records, but then the datatype would have to be
> varchar(100) I suppose and we'd have to d alot of validating/converting.
> But maybe this is the better way to go?
>
> Or do you recommend another way? Would there be some sort of app.config
> specific to each feedlot that we stored somewhere?
>
> Thanks,
> Ron
>



 
Reply With Quote
 
Ronald S. Cook
Guest
Posts: n/a
 
      27th Aug 2006
But the same app is installed at 12 sites and each site's specific values
must be retrieved and used. I wouldn't think we'd maintain a separate
app.config for each feedlot. Or should we?

Thanks,
Ron


"Nicholas Paldino [.NET/C# MVP]" <(E-Mail Removed)> wrote in
message news:%(E-Mail Removed)...
> Ron,
>
> The app.config file is exactly what you should be doing. You can set
> the values you need in the app.config file, and then read them easily.
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - (E-Mail Removed)
>
> "Ronald S. Cook" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> We have a .NET Win app that runs at 12 different cattle feeding lots.
>> Each lot runs an isolated instance of our app using its own SQL Server
>> instance.
>>
>> For overall settings specific to a feedlot, we're maintaining those
>> values right now in the database. But I'm not sure its the best way to
>> do it. You see, we have a table "tblFeedlot" with about 20 columns BUT
>> then only one record in the table.
>>
>> I thought maybe the table should have just two columns "Name" and "Value"
>> to and have 20 records, but then the datatype would have to be
>> varchar(100) I suppose and we'd have to d alot of validating/converting.
>> But maybe this is the better way to go?
>>
>> Or do you recommend another way? Would there be some sort of app.config
>> specific to each feedlot that we stored somewhere?
>>
>> Thanks,
>> Ron
>>

>
>



 
Reply With Quote
 
Nicholas Paldino [.NET/C# MVP]
Guest
Posts: n/a
 
      27th Aug 2006
Ronald,

Yes, you would have a separate app.config file for each feed lot.
That's the whole point, this is where you would differentiate in the
settings. Basically, your configuration file would look like this:

<configuration>
<appSettings>
<add key="SomeKey" value="SomeValueForFeedLot1" />
</appSettings>
</configuration>

At another feed lot, you would have:

<configuration>
<appSettings>
<add key="SomeKey" value="SomeValueForFeedLot2" />
</appSettings>
</configuration>

And so on. Granted, you could write a configuration section handler,
but for something like this, this would do just fine, I think.

Then, to access these values in code:

// Get the "SomeKey" value:
string someKeyValue = ConfigurationManager.AppSettings["SomeKey"];

This will require a reference to System.Configuration.dll and this .NET
2.0-specific. In .NET 1.1 and before, you can do the same thing in the
app.config file but use this:

// Get the "SomeKey" value:
string someKeyValue = ConfigurationSettings.AppSettings["SomeKey"];


--
- Nicholas Paldino [.NET/C# MVP]
- (E-Mail Removed)


"Ronald S. Cook" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> But the same app is installed at 12 sites and each site's specific values
> must be retrieved and used. I wouldn't think we'd maintain a separate
> app.config for each feedlot. Or should we?
>
> Thanks,
> Ron
>
>
> "Nicholas Paldino [.NET/C# MVP]" <(E-Mail Removed)> wrote
> in message news:%(E-Mail Removed)...
>> Ron,
>>
>> The app.config file is exactly what you should be doing. You can set
>> the values you need in the app.config file, and then read them easily.
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - (E-Mail Removed)
>>
>> "Ronald S. Cook" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> We have a .NET Win app that runs at 12 different cattle feeding lots.
>>> Each lot runs an isolated instance of our app using its own SQL Server
>>> instance.
>>>
>>> For overall settings specific to a feedlot, we're maintaining those
>>> values right now in the database. But I'm not sure its the best way to
>>> do it. You see, we have a table "tblFeedlot" with about 20 columns BUT
>>> then only one record in the table.
>>>
>>> I thought maybe the table should have just two columns "Name" and
>>> "Value" to and have 20 records, but then the datatype would have to be
>>> varchar(100) I suppose and we'd have to d alot of validating/converting.
>>> But maybe this is the better way to go?
>>>
>>> Or do you recommend another way? Would there be some sort of app.config
>>> specific to each feedlot that we stored somewhere?
>>>
>>> Thanks,
>>> Ron
>>>

>>
>>

>
>



 
Reply With Quote
 
Ronald S. Cook
Guest
Posts: n/a
 
      27th Aug 2006
Thanks for the advice, Nicholas. I should have mentioned, though, that
through the application, the values will need to be updated. I think this
forces the data back to the database.

Assuming you agree, do you like one record with many columns, or just
key/value columns and many records in a table.

Thanks for the responses,
Ron


"Nicholas Paldino [.NET/C# MVP]" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> Ronald,
>
> Yes, you would have a separate app.config file for each feed lot.
> That's the whole point, this is where you would differentiate in the
> settings. Basically, your configuration file would look like this:
>
> <configuration>
> <appSettings>
> <add key="SomeKey" value="SomeValueForFeedLot1" />
> </appSettings>
> </configuration>
>
> At another feed lot, you would have:
>
> <configuration>
> <appSettings>
> <add key="SomeKey" value="SomeValueForFeedLot2" />
> </appSettings>
> </configuration>
>
> And so on. Granted, you could write a configuration section handler,
> but for something like this, this would do just fine, I think.
>
> Then, to access these values in code:
>
> // Get the "SomeKey" value:
> string someKeyValue = ConfigurationManager.AppSettings["SomeKey"];
>
> This will require a reference to System.Configuration.dll and this .NET
> 2.0-specific. In .NET 1.1 and before, you can do the same thing in the
> app.config file but use this:
>
> // Get the "SomeKey" value:
> string someKeyValue = ConfigurationSettings.AppSettings["SomeKey"];
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - (E-Mail Removed)
>
>
> "Ronald S. Cook" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> But the same app is installed at 12 sites and each site's specific values
>> must be retrieved and used. I wouldn't think we'd maintain a separate
>> app.config for each feedlot. Or should we?
>>
>> Thanks,
>> Ron
>>
>>
>> "Nicholas Paldino [.NET/C# MVP]" <(E-Mail Removed)> wrote
>> in message news:%(E-Mail Removed)...
>>> Ron,
>>>
>>> The app.config file is exactly what you should be doing. You can set
>>> the values you need in the app.config file, and then read them easily.
>>>
>>>
>>> --
>>> - Nicholas Paldino [.NET/C# MVP]
>>> - (E-Mail Removed)
>>>
>>> "Ronald S. Cook" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> We have a .NET Win app that runs at 12 different cattle feeding lots.
>>>> Each lot runs an isolated instance of our app using its own SQL Server
>>>> instance.
>>>>
>>>> For overall settings specific to a feedlot, we're maintaining those
>>>> values right now in the database. But I'm not sure its the best way to
>>>> do it. You see, we have a table "tblFeedlot" with about 20 columns BUT
>>>> then only one record in the table.
>>>>
>>>> I thought maybe the table should have just two columns "Name" and
>>>> "Value" to and have 20 records, but then the datatype would have to be
>>>> varchar(100) I suppose and we'd have to d alot of
>>>> validating/converting. But maybe this is the better way to go?
>>>>
>>>> Or do you recommend another way? Would there be some sort of
>>>> app.config specific to each feedlot that we stored somewhere?
>>>>
>>>> Thanks,
>>>> Ron
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Nicholas Paldino [.NET/C# MVP]
Guest
Posts: n/a
 
      27th Aug 2006
Ronald,

I don't necessarily agree. It depends on how often those values are
updated.

If the values are ones that are not user-controlled, meaning that you
set them and change them when necessary, then the database is the wrong
place for this, it should be in the app.config file.

If the values are user-controlled, and changed with any sort of
frequency, then yes, the database is the better place. I would most likely
have a table with typed columns for specific values. It's easier to perform
other operations in the database than if you had a table with a key/value
pair.


--
- Nicholas Paldino [.NET/C# MVP]
- (E-Mail Removed)

"Ronald S. Cook" <(E-Mail Removed)> wrote in message
news:%23$(E-Mail Removed)...
> Thanks for the advice, Nicholas. I should have mentioned, though, that
> through the application, the values will need to be updated. I think this
> forces the data back to the database.
>
> Assuming you agree, do you like one record with many columns, or just
> key/value columns and many records in a table.
>
> Thanks for the responses,
> Ron
>
>
> "Nicholas Paldino [.NET/C# MVP]" <(E-Mail Removed)> wrote
> in message news:(E-Mail Removed)...
>> Ronald,
>>
>> Yes, you would have a separate app.config file for each feed lot.
>> That's the whole point, this is where you would differentiate in the
>> settings. Basically, your configuration file would look like this:
>>
>> <configuration>
>> <appSettings>
>> <add key="SomeKey" value="SomeValueForFeedLot1" />
>> </appSettings>
>> </configuration>
>>
>> At another feed lot, you would have:
>>
>> <configuration>
>> <appSettings>
>> <add key="SomeKey" value="SomeValueForFeedLot2" />
>> </appSettings>
>> </configuration>
>>
>> And so on. Granted, you could write a configuration section handler,
>> but for something like this, this would do just fine, I think.
>>
>> Then, to access these values in code:
>>
>> // Get the "SomeKey" value:
>> string someKeyValue = ConfigurationManager.AppSettings["SomeKey"];
>>
>> This will require a reference to System.Configuration.dll and this
>> .NET 2.0-specific. In .NET 1.1 and before, you can do the same thing in
>> the app.config file but use this:
>>
>> // Get the "SomeKey" value:
>> string someKeyValue = ConfigurationSettings.AppSettings["SomeKey"];
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - (E-Mail Removed)
>>
>>
>> "Ronald S. Cook" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> But the same app is installed at 12 sites and each site's specific
>>> values must be retrieved and used. I wouldn't think we'd maintain a
>>> separate app.config for each feedlot. Or should we?
>>>
>>> Thanks,
>>> Ron
>>>
>>>
>>> "Nicholas Paldino [.NET/C# MVP]" <(E-Mail Removed)> wrote
>>> in message news:%(E-Mail Removed)...
>>>> Ron,
>>>>
>>>> The app.config file is exactly what you should be doing. You can
>>>> set the values you need in the app.config file, and then read them
>>>> easily.
>>>>
>>>>
>>>> --
>>>> - Nicholas Paldino [.NET/C# MVP]
>>>> - (E-Mail Removed)
>>>>
>>>> "Ronald S. Cook" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> We have a .NET Win app that runs at 12 different cattle feeding lots.
>>>>> Each lot runs an isolated instance of our app using its own SQL Server
>>>>> instance.
>>>>>
>>>>> For overall settings specific to a feedlot, we're maintaining those
>>>>> values right now in the database. But I'm not sure its the best way
>>>>> to do it. You see, we have a table "tblFeedlot" with about 20 columns
>>>>> BUT then only one record in the table.
>>>>>
>>>>> I thought maybe the table should have just two columns "Name" and
>>>>> "Value" to and have 20 records, but then the datatype would have to be
>>>>> varchar(100) I suppose and we'd have to d alot of
>>>>> validating/converting. But maybe this is the better way to go?
>>>>>
>>>>> Or do you recommend another way? Would there be some sort of
>>>>> app.config specific to each feedlot that we stored somewhere?
>>>>>
>>>>> Thanks,
>>>>> Ron
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Won't maintain default printer settings Paula Windows XP Print / Fax 7 21st Feb 2009 07:23 AM
How to maintain settings between two different printers? MaryL Microsoft Word New Users 3 22nd Nov 2008 05:21 PM
how to maintain settings when calling a second macro =?Utf-8?B?SmltIEphY2tzb24=?= Microsoft Excel Programming 2 4th Oct 2006 05:00 PM
Windows Firewall Won't Maintain Settings Jeff R. Windows XP General 2 6th Oct 2004 05:47 PM
Toolbar Wont Maintain Settings Ric Kaysen Windows XP Internet Explorer 1 23rd Apr 2004 11:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:56 AM.