Object Cannot be cast from DBNull to other types
Posted on 2004-08-23
I am having a DateTimePicket control on a form which is bound to a column in a dataset. This is the binding of DateTimePicker control:
dateTimeGradDate.DataBindings.Add(New Binding("Value", dsPersonalInfo.Tables("personalInfo"), "gradDate"))
The gradDate will be NULL in the data base. But, I used a default value of current date when filling the dataset. That code is as follows:
dsPersonalInfo.Tables("personalInfo").Columns("gradDate").DefaultValue = System.DateTime.Today
When I run the program, I get "Object Cannot be cast from DBNull to other types" exception
How do I handle this exception?