good data-driven place to store default values?

J

jason

so i have a database schema, a .NET object library .dll, and an ASP
classic web application.

i'm wondering where in this setup i should place default values for
fields/columns of forms/objects/rows.

SQL Sever doesn't seem like a good candidate, because i'm using stored
procedures for all inserts. these procs use input parameters for each
of the values in case there IS a value other than default, but since
the parameters are optional, they are defined with the = null. so these
mechanisms basically completely circumvent the default values, because
either a value is specified by the caller of the proc, and that value
is stored, or the value is not specified by the caller, and a null is
stored. either way, no default values from the table definition.

The object library seems like a decent place, except that i would love
for it to be data driven. i suppose each object could keep track of all
of its own default variables. part of the constructor could be to go
find its default-value definition file, and load them up that way. does
anyone foresee any major architectural problems with this?

And the last option is to put the default value definitions in the ASP
code somehow, probably through a constants file, and value comparisons.
Much less elegant than putting them in the object library, but pretty
simple, too.

Thoughts? comments? Suggestions?

Thanks,

Jason
 
W

William \(Bill\) Vaughn

Yes, if you create a Parameter object and append it to the Parametes
collection at runtime, the Parameter.Value you supply overrides the sp-based
default value. This default is only used if the named Parameter is NOT
appended to the Parameters collection. This is a viable option, but it takes
additional code.

There are a number of places to save your default settings:
Use the Web.Config file
Use SQL Server Extended properties. These are visible to the SP (or your
application). I wrote an article about this approach a couple of years ago.
See www.betav.com/articles.htm.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
A

Adrian Moore

Jason,

Why not make the sproc inputs = default value instead of = null? This will
still make them optional.

Ad.
 
J

jason

aha! i didn't know that was an option, but it sure makes sense. seemed
like a pretty significant limitation otherwise. thanks for pointing
this out, the database is an option again.

and thanks to the spiffy way tables are defined, this really is as good
as data-driven.

thanks again.
 
J

jason

there's no way to derive the default value of sproc inputs from the
table default definition is there?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top