DateTimePicker Checked-property question

M

Mika M

Hi!

I have bound DateTimePicker to the DataSet DataTable's field like...

dtpMyDateTime.DataBindings.Add(New Binding("Text", dt, "MyDateTimeField"))

....and ShowCheckBox-property = True

Saving date into database table using DateTimePicker is working fine, but I
assumed when Checked-box is NOT checked then dtpMyDateTime.Value should be
something like "NULL" or DbNull.Value or Nothing, but it's not working like
this way :(

So how can I choose "not date selected" ie. save NULL into database table
using DateTimePicker?
 
E

Earl

Something like this:

If DTPicker.Checked = True Then
ds.Tables("dt").Rows(0)("SaleDate") = DTPicker.Value
Else
ds.Tables("dt").Rows(0)("SaleDate") = DBNull.Value
End If
 
M

Mika M

Earl said:
Something like this:

If DTPicker.Checked = True Then
ds.Tables("dt").Rows(0)("SaleDate") = DTPicker.Value
Else
ds.Tables("dt").Rows(0)("SaleDate") = DBNull.Value
End If
Thanks Earl!

Yes I quessed and made this kind of solution too, but was wondering is this
the right one to do - but it seems to work like this way anyway.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top