Follow via:
RSS
Email Alert
Question
0 Votes
+ -

Saving ASP web application configuration in SQL database

I am in the process of building a simple web app for our company. I have a friend that mentioned about saving the application configuration in a database.

Please explain this concept or point out some sites that will give me more information about this technique.

Thanks,
Steve
Tags: programming
Updated - 21st Aug 2007

Answers (3)

0 Votes
+ -
simple config
I do not know is your after something specific, but you basically create a table in the database with 2 columns, set one as a identy column use nvarchar(255) as the data type, set the other column as ntext. The Identity becomes your Key and the Ntext becomes your value, this works just like a hashtable or any other dictionary type collection object. Then just create a couple methods in a common include file one called getconfig, one called set config. Those set and get your values from your table so anytime you want a value from the database. You call getconfig("KeyName") to set a value you call setconfig("KeyName","Value").

If you really want to get fancy and get performance then acahe the config values in the application variables section of your site, so then when you call getconfig it check to see if the value is in memory before going to the database which is a lot faster, if it is not in memory then get the value from the database and put it in memory before returning it to you. Simple as that, similar to any hash table or dictionary collection. I do not know of any sites that show this though. This is really just basic dictionary collection style stuff.
23rd Aug 2007
0 Votes
+ -
Another approach...
I like Doom's method, and have used it many times. In fairness I thought I should mention another approach. The configuration section of .NET can be descended from/overridden to read/write from anything you can write the code for. There is an article on MSDN about using this approach.
23rd Aug 2007

Replies

This way is much better, in reality I would create custom config handlers and using config sections for what you are wanting and go from there. Using web config in a .net environment is a much prefered aproach. I guess we would need clarification if this is ASP or ASP.net.

I much prefer the web.config in .net because it is easy to work with and edit randomly like a developer might want to. Plus all the config information can be writen right out in a trace so you can see what is going on at the time. This really helps trouble shooting things. But if you are going with Classic asp. I would go with my previous post.
BOUND4DOOM 23rd Aug 2007
0 Votes
+ -
Don't overlook metabase backup
If the only need is for backup, and this is old ASP not ASP.net, then you have an option to backup the metabase.

If your ASP site has a non-flat tree structure, that doesn't translate directly to a keyword=value list, you need a way to represent the branching.
23rd Aug 2007
Answer the question
Formatting +
BB Codes - Note: HTML is not supported in forums
  • [b] Bold [/b]
  • [i] Italic [/i]
  • [u] Underline [/u]
  • [s] Strikethrough [/s]
  • [q] "Quote" [/q]
  • [ol][*] 1. Ordered List [/ol]
  • [ul][*] · Unordered List [/ul]
  • [pre] Preformat [/pre]
  • [quote] "Blockquote" [/quote]

Join the TechRepublic Community and join the conversation! Signing-up is free and quick, Do it now, we want to hear your opinion.