Here's an example of using a nullable type. They are
good to use when you need to know if a number is 0 or Null,
because those are two different things, especially if you
are doing numerical calculations.
Dim IntegerData As Nullable(Of Integer)
If IntegerData.HasValue Then
Console.WriteLine("IntegerData = " & IntegerData.ToString)
Else
Console.WriteLine("IntegerData = Null.")
End If
If you read data from a database, you have to check for DBNull
and act accordingly.
IntegerData = Nothing
If NOT IsDBNull(myRow.ProductCode) Then
IntegerData = myRow.ProductCode
End If
Another syntax for this is:
If myRow.ProductCode IsNot DbNull.Value Then
...
Robin S.
------------------------
"MobileBoy36" <Mo*********@gmail.comwrote in message
news:45***********************@news.skynet.be...
Hi all,
Nullable types were announced as new handy stuff in .NET 2.0
But it seems like the datareader doesn't support nullable types.
You have still to check for "IsDbNull".
So, are Nullable Types useful at this moment? Do you get any benefit
using them (at this moment)?
Is Microsoft going to change this?
Best regards,
Mobile Boy