Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / May 2005

Tip: Looking for answers? Try searching our database.

good data-driven place to store default values?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jason - 24 May 2005 21:59 GMT
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
William \(Bill\) Vaughn - 24 May 2005 22:15 GMT
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.

Signature

____________________________________
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.
__________________________________

> so i have a database schema, a .NET object library .dll, and an ASP
> classic web application.
[quoted text clipped - 27 lines]
>
> Jason
jason - 24 May 2005 22:29 GMT
thank you very much for the input and the link!
Adrian Moore - 24 May 2005 22:19 GMT
Jason,

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

Ad.

> so i have a database schema, a .NET object library .dll, and an ASP
> classic web application.
[quoted text clipped - 27 lines]
>
> Jason
jason - 24 May 2005 22:33 GMT
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.
jason - 25 May 2005 16:23 GMT
there's no way to derive the default value of sproc inputs from the
table default definition is there?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.