Search code examples
databasevb.netwinformsdatetimepicker

NoNullAllowedException in DateTimePicker


I'm working on a small application. I want to set today's value as the default value to the datetimepicker. Therefore used the form_load event and set the date like this:

DateDateTimePicker.Value = Date.Today

If I select a date from the picker it works fine. But if I don't it shows a null exception when saves it.

The exception occurs in

Me.SaleBindingSource.EndEdit()

Exception is

'System.Data.NoNullAllowedException'

Solution

  • You cant have null in datetimepicker but set it to datetime.min value and tgen perform validations