Question DateTimePicker Value Is Null

Melvin

New member
Joined
Nov 5, 2009
Messages
3
Programming Experience
1-3
Hi,

So I have a windows form that that needs data entry from users. The data entered would be then transferred into an SQL database. My dilemma is that if I don't change the default date loaded in the datetimepicker during form load, it is treated as a null value hence saving a null value to the database for the date. In my program's case its not being saved because i have set that all fields are required.

Question is how do I make the initial value of the datetimepicker not null especially when users don't bother to change the initial value of it during form load?

I hope I stated my problem clear.. Thanks in advance too.
 
Don't change it "during" Form_Load, change it "in" Form_Load with code
VB.NET:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        DateTimePicker1.Value = Now.Date
End Sub
 
Back
Top