Treating NULL database values in classes and Form fields.

Tech-Archive recommends: Fix windows errors by optimizing your registry



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



Relevant Pages

  • Re: YYYYMMDD
    ... > How can I validate a numeric data from database against this format ... Vbscript documentation is available here: ... Please reply to the newsgroup. ...
    (microsoft.public.scripting.vbscript)
  • Re: Treating NULL database values in classes and Form fields.
    ... It sounds like you might be using .NET in which case you could use Nullable types. ... Also search the web for ORM to see the different ways different object-relational mappers deal with database nullable fields when mapped to an object model. ... When I read numeric data from a database into a class object and then ... They can't be stored as DBNulls assuming I am using ...
    (microsoft.public.vb.general.discussion)
  • Re: Data Type
    ... If it isn't really a number, don't 'type' it as a numeric data type. ... And if you are concerned about "the efficiency" of the database, ... This author may have received products and services mentioned ...
    (microsoft.public.access.tablesdbdesign)
  • Re: YYYYMMDD
    ... > How can I validate a numeric data from database against this format ... > four digit represents the year and the preceding 2 digits represents the ... DateOkay = False ...
    (microsoft.public.scripting.vbscript)
  • =?Utf-8?Q?RE:_How_to_destroy_/_=E2=80=9Cdisable_to?= =?Utf-8?Q?_open=E2=80=9D=3F?=
    ... "kishorboraste" wrote: ... “disable to open” my database on or after the specified date. ... from queries & to do some arithmetical calculation on the numeric data. ...
    (microsoft.public.access.tablesdbdesign)