Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cannot assign a Blank/Null date
Message
From
17/04/2007 12:29:24
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01216819
Message ID:
01216822
Views:
19
>I have a DateTime field in a table and sometimes I want to store a blank /null data there (The field is set up in Sql Server to accept nulls)
>I have the following code
>string lcNull = null;
>if (DOC_DATERE.SelectedValue.ToString().Trim() == "")
> {
> DOC_DATERE.SelectedValue = lcNull;
> }
>... but this throws a run time error of:-
> Object Reference not set to an instance of an object.
>If I space out the field I get this error, if there is a valid date there its ok.
>
>Anybody know how to get a null date into the field ?

This returns an empty date:
        ' Return an empty date
        ' expT1 Date
        Public Function GetEmptyDate() As Date
            Return New Date(1899, 12, 30, 0, 0, 0)
        End Function
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform