[thelist] Testing for the various NULL's

David.Cantrell at Gunter.AF.mil David.Cantrell at Gunter.AF.mil
Thu Dec 5 10:29:01 CST 2002

>I've got a table cell that was defaulted to "<NULL>" at the time of
>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.

This is because NULL is not a blank string. NULL does not even equal NULL.
NULL is simply a form to the void, so to Zen-speak. :)

Literally, though. In order to reset the field to NULL you would have to
explicity pass the value NULL (no quotes, it's a keyword) instead of a
string. Otherwise you are telling the database "here is a string with zero
length", which is considerably different than saying "here is absolutely

This is the same as trying to equate NULL with zero. If you give something a
value of zero, then it is a number with a value. If it has a value of NULL,
it has NO value, numeric or otherwise. Period.

Think of it as the value getting hit by the Death Star's laser gun. Boom.
Disintegrated. Gone. End of story. :)

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

Try this:
	If Manager.Fields.Item("Address2").Value Is Not Null

When you write "if var1 <> Null" then the whole expression "var1 <> Null"
evaluates false, and therefore the if statement doesn't execute, because if
statements only execute when the final expression is true. It evaluates
false because no matter what the value of var1 is, it can NEVER equal a NULL
value. Even if var1 had a value of NULL, it still wouldn't equal NULL, so
the test fails and the if statement is skipped.

Fun, eh? :)


More information about the thelist mailing list