Empty Strings and Nulls

Here is an example of the type of thing you want to do when you're concerned that a database column might return a Null value:

strCustomerName = rsCustomers.Fields("Name").Value
If IsNull(strCustomerName) Then
strCustomerName = ""
End If

Here we are assigning the value of the "Name" column in a database table to the variable strCustomerName. If the Name column in the database allows Null values, then we need to be concerned that we might end up with a Null value in ur variable. So we use IsNull ( ) to test the value.If IsNull ( ) returns True, then we assign an empty string to the variable instead. Empty strings are much more friendly then Nulls. Here is a handy shortcut that achieves the same exact thing as the above code.

strCustomerName = "" & rsCustomers.Fields("Name").Value

Here we are appending an empty string to the value coming from the database. This takes advantage of VBSctipt's implicit type coercion behavior. Concatenating an empty string with a Null value transforms that value into an empty string, and concatenating an empty string to a valid string has not effect at all, so it is a win-win situation; if the value is Null, it gets fixed, and if it's not Null, it's left alone.

First