In MS Access VBA, there is a terrific function, Nv(). It takes two arguments. The first argument is tested for whether it is Null or not.
If it is
[u]not</u> Null, the first argument is returned.
If it
[u]is</u> Null, the second argument is returned.
So then, the following:
Code:
Dim x As Variant
Dim v As Variant
x = Null
v = Nz(x, "") ' v now is an empty string
v = Nz(x, 5) ' v now is an integer, 5.
x = 1
v = Nz(x, "") ' v now equals 1
x = "Hey..."
v = Nz(x, "") ' v now equals "Hey..."
I liked this so much, I added that functionality, with the same exact syntax, to a VB6 library of functions that I included with my projects.
I would much prefer to find that .NET has covered this, than to once again write my own...
Can it be that MS
[u]still</u> has not added this functionality to
VB? Oracle has a function that will do the same thing in SQL (NVL()), Access has itâit seems that more than one company has found this to be a useful process...
I am presuming that ADO.NET still produces Nulls when the contents of the DB for a given field in a given row is carrying a null in the data.