Date column does not allow nulls

johncassell

Well-known member
Joined
Jun 10, 2007
Messages
120
Location
Redcar, England
Programming Experience
Beginner
Hi There,

was hoping someone could help me with this..

I have a datetimepicker on my form bound to a column in my table (The column does not allow nulls).

The datetimepicker is populated with a date when I hit 'Save' but it still says column does not allow nulls.

I am trying to populate it with something so why is it saying this?

Thanks in advance for any guidance.

John
 
Hi There,

funny thing was yesterday I had this cracked and for some reason today it wasn't working. I had to return to last nights backup version for numerous reasons and so its working again.

I still don't know why it wasn't working but I am going to leave it alone and not tempt fate by trying anything else on it.

Thanks for the replies though, much appreciated.

John
 
I'd tend to agree with Arg81. Either:

You have bound dtp.Text when you should have bound dtp.Value
You have bound both dtp.Text and dtp.Value

Setting a default value for this column every time you add new might be a good idea. Though you set the col to not allow nulls, the default value is probably null. DateTimePicker is a crappy component and developers have complained for years that it doesnt handle nulls (Google for SmartFieldPackEditor) so if your underlying value is null, the dtp might still be showing a date that it wont commit unless you change it -> you think theres a date in the column when there isnt, hit save, and get the no nulls allowed error
 
that's what was happening to me. The DTP was showing the date that the user wanted (normally current date) but they saved the date wasn't commited.

I then set it on form_load so that me.datetimepicker.value = date.today()

I never have a requirement to store the time, only the date so I use .today() instead of .now()
 
Back
Top