[thelist] Testing for the various NULL's

Rob Smith rob.smith at THERMON.com
Thu Dec 5 10:17:01 CST 2002

Hi List,

The debate of the existence/quantity of zero has been going on for ages. My
problem is a slight mutation of the debate and I'm having a bit of trouble
testing for the various sets of NULL's.

Tech Background:
* SQL Server 2000
* ASP (version in this case doesn't matter)
* HTML form

I've got a table cell that was defaulted to "<NULL>" at the time of creation
of the row. I would insert an text string into the cell via an INSERT sql
query in ASP. Using an HTML form, the user would "delete" the contents in
the HTML form cell and click "Update Record". Well the UPDATE query would
insert whatever was in that blank, which is an empty string. Now my Table
Cell does not have "<NULL>" in it, but a cell of nothing; just blank.

Next segment: When I want to Display the other various information from the
HTML form back to the screen, but I don't want to print anything that was
left blank on the HTML form. So...

   if manager.fields.item("Address2").value <> "" then
       response.write(manager.fields.item("Address2").value & "<br>")
   end if

Unfortunately, this works while the cell is "<NULL>" but not when the cell
is left blank. I've tried these other tests and still no success to skip
this line of output:

if manager.fields.item("Address2").value <> "" then
if not manager.fields.item("Address2").value = "" then
if manager.fields.item("Address2").value <> NULL then
if not manager.fields.item("Address2").value = NULL then
I've tried the isNULL keyword but ASP doesn't like it.

For some odd reason, a blank cell behaves quite differently than a "<NULL>"

Could anyone help me please?


p.s. Even odder still, I've got two identical pieces of code (copy and
pasted) that exert the same behavior. One works to skip the code, the other
doesn't. Like I said, these pieces of code are identical...

More information about the thelist mailing list