The Date variable type cannot be null. It must have a value.
Most people use Date.MinValue (or Date.MaxValue) to represent a null date in
their code.
Example:
Dim MyDate as Date = Date.MinValue
As for inserting it in the database, the other guys already specified that
DBNull.Value is what you'll want to use.
The better news is that in .NET 2.0 all variable types will be nullable.
Here's more info:
http://www.panopticoncentr
Main Topics
Browse All Topics





by: DhaestPosted on 2008-12-15 at 03:20:08ID: 23172372
MSDN:
eforge.net /
"Unlike reference types, it is not possible for a value type to contain the null value."
DateTime is a value type.
Since DateTime is a Value Type (not a Reference Type), so you can't assign
null or Nothing to it. If you want to do something simelar, you could use
the MinValue property:
if(myDate == DateTime.MinValue)
{
//myDate is empty
}
Or you can use the Nullable Types library:
http://nullabletypes.sourc