Treating NULL database values in classes and Form fields.
- From: YaHozna <YaHozna@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 19 Feb 2009 04:25:02 -0800
Been wondering about this one for a while so I thought I'd see what other
people do about it.
When I read numeric data from a database into a class object and then
display the data on a Form what are the different ways out there for dealing
with values that are NULL in the database? Let me explain.
I may have a number of numeric values in my database that are currently NULL
- i.e. not every value has been supplied by the user. When they are read into
my application the associated Form fields should then display nothing rather
than zeroes. However when these values are read into a class object what
should they be stored as? They can't be stored as DBNulls assuming I am using
numeric class property values. In the past where a value in the database is
NULL I have set the associated property value to -1. I can then set Form
fields associated with property values that are -1 to blank. Alternatively I
can use Object property values which means I can set them to DBNull for
associated database values that are NULL. Neither of these are particularly
satisfactory.
What are my other options here?
Regards,
Gordon.
.
- Follow-Ups:
- Re: Treating NULL database values in classes and Form fields.
- From: Cor Ligthert[MVP]
- Re: Treating NULL database values in classes and Form fields.
- From: Bill McCarthy
- Re: Treating NULL database values in classes and Form fields.
- From: Jeff Johnson
- Re: Treating NULL database values in classes and Form fields.
- From: David Kerber
- Re: Treating NULL database values in classes and Form fields.
- Prev by Date: Re: How to know what files to redistribute?
- Next by Date: Center Text using printer object
- Previous by thread: Help required MSDN
- Next by thread: Re: Treating NULL database values in classes and Form fields.
- Index(es):
Relevant Pages
|