Dealing with NULLs

A

Angela

Hi

I am building a very simple data entry system with many forms and
input textboxes.

When I leave any part of the form empty (it allows nulls) it seems to
touch the field in the DB and the field is no longer NULL.

I have written a script to test for empty textboxes and insert DB.NULL
which is fine but when I want to load the data back into the form
(i.e. NULL value into a textbox) it gives me an error.

Is it a bit overkill to replace 'no data' with DB.Nulls before
updating the DB and then do another test to test for DB.Nulls and
replace with empty string when retrieving the data from DB??
 
P

Patrice

The ToString method will return an empty string if the field is null (does a
check first but quite sure). This cehck should performed in your DB access
layer avoiding to do it again and again.

My personal preference is to avoid NULL if possible especially for
characters fields. This is not a problem as long as you don't have to
distinguish between a field that is an empty string and that holds NULL(for
example if a name is blank it's quite obvious the info is missing, for this
I use NOT NULL and uses a empty string).

For dates and numbers you don't have the same issue the number or date is
either "visible" or is a NULL value.

Patrice
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top