John Baird
Coatesville, Pennsylvania, United States
Hi John, thnaks for your reply.
I changed ny code to :
if (DOC_DATERE.SelectedValue.ToString().Trim() == "")
{
DOC_DATERE.SelectedValue = DBNull.Value;
}
It still comes up with the same message...lookin at it a bit close it seems to be the If (doc_datere.... bit is causing the problem.
Is there another way to trst if this field is blank ?
Regards,
Gerard
>Use DBNull.Value for datatables/SQL tables.
>
>
>
>>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 ?
>>
>>Regards,
>>Gerard
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only