Re: Treating NULL database values in classes and Form fields.
- From: YaHozna <YaHozna@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 23 Feb 2009 06:55:02 -0800
Thanks for the response, Cor. As expected there were a number suggestions,
all of them equally valid. Plenty to think about.
Regards,
Gordon.
"Cor Ligthert[MVP]" wrote:
YaHozna,.
In my idea is this question valid for every way of programming. It is in
fact a question how to handle the can be zero Null addition to a column type
in SQL.
It has been forever confusing. A Null in SQL means in fact unused. It is up
to you what you make from that. Mostly is that for a numeric field simple
zeros.
However in most cases a simple null wil work the most simple.
In VB8 you can use nullable fields, but for me is this a kind of creating it
confirm C type languages. A blob field makes probably sense to avoid that
filled with rubish in a database. A null value field is in my perception a
kind of micro optimizing from 1970 or maybe 1980 but not from this
millenium.
This is a longtime problem and longwhile users have asked to do something
about that problem. In SQL Server 2008 is beside the possibilitie to
declare a column as can be Null column, the possibility to declare a column
as a can be "Empty" column.
Cor
"YaHozna" <YaHozna@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:49CE30C7-D97D-4C3E-A9E4-61FA6D844682@xxxxxxxxxxxxxxxx
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.
- References:
- Treating NULL database values in classes and Form fields.
- From: YaHozna
- Re: Treating NULL database values in classes and Form fields.
- From: Cor Ligthert[MVP]
- Treating NULL database values in classes and Form fields.
- Prev by Date: Re: Treating NULL database values in classes and Form fields.
- Next by Date: Re: Treating NULL database values in classes and Form fields.
- Previous by thread: Re: Treating NULL database values in classes and Form fields.
- Next by thread: Center Text using printer object
- Index(es):
Relevant Pages
|