By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,712 Members | 1,344 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,712 IT Pros & Developers. It's quick & easy.

datetimepicker dataset

P: n/a
When adding a new record from my form, I pre-set my DateTimePicker's value to
System.DateTime.Today
Since the "Today" value is used most of the time, the user doesn't need to
select a date from the DateTimePicker, since the default is shown. My problem
is, if the user does not choose a value from the DateTimePicker (because
using the default is good enough), then during database update, the date
value is not saved to the database; while if user choose another value other
then the default, the value can be saved to the database successfully. Is
there a way to ensure the default value can be saved to the database?
Nov 21 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
If Then

Else

End If

"Clamara" <Cl*****@discussions.microsoft.com> wrote in message
news:C6**********************************@microsof t.com...
When adding a new record from my form, I pre-set my DateTimePicker's value
to
System.DateTime.Today
Since the "Today" value is used most of the time, the user doesn't need to
select a date from the DateTimePicker, since the default is shown. My
problem
is, if the user does not choose a value from the DateTimePicker (because
using the default is good enough), then during database update, the date
value is not saved to the database; while if user choose another value
other
then the default, the value can be saved to the database successfully. Is
there a way to ensure the default value can be saved to the database?

Nov 21 '05 #2

P: n/a
it's a joke???

"Earl" wrote:
If Then

Else

End If

"Clamara" <Cl*****@discussions.microsoft.com> wrote in message
news:C6**********************************@microsof t.com...
When adding a new record from my form, I pre-set my DateTimePicker's value
to
System.DateTime.Today
Since the "Today" value is used most of the time, the user doesn't need to
select a date from the DateTimePicker, since the default is shown. My
problem
is, if the user does not choose a value from the DateTimePicker (because
using the default is good enough), then during database update, the date
value is not saved to the database; while if user choose another value
other
then the default, the value can be saved to the database successfully. Is
there a way to ensure the default value can be saved to the database?


Nov 21 '05 #3

P: n/a
If ...... Then

yourDate = DateTimePicker1.Value.Date

Else

yourDate = Now.Date

End If

"Clamara" <Cl*****@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
it's a joke???

"Earl" wrote:
If Then

Else

End If

"Clamara" <Cl*****@discussions.microsoft.com> wrote in message
news:C6**********************************@microsof t.com...
> When adding a new record from my form, I pre-set my DateTimePicker's
> value
> to
> System.DateTime.Today
> Since the "Today" value is used most of the time, the user doesn't need
> to
> select a date from the DateTimePicker, since the default is shown. My
> problem
> is, if the user does not choose a value from the DateTimePicker
> (because
> using the default is good enough), then during database update, the
> date
> value is not saved to the database; while if user choose another value
> other
> then the default, the value can be saved to the database successfully.
> Is
> there a way to ensure the default value can be saved to the database?


Nov 21 '05 #4

P: n/a
I think you misunderstand me...

PLEASE TRY THIS PLEASE TRY THIS PLEASE TRY THIS PLEASE TRY THIS

try this with vb.net 2003

create with the dataform wizard a form that bind to a simple sql table with
productID and dateofproduct (datetime and not nullable).
If you show the form the load event put as dateofproduct default the today's
date but if you try to update the dataset without touch the datetimepicker
control the dataset reject to update cause the datetimepicker value is null.
While if I touch the datetimepicker control and i choose a date the update
works.

My problem
is, if the user does not choose a value from the DateTimePicker (because
using the default is good enough) the update doesn't works.

I haved try to set datetimepicker.value = now() during the load event but it
doesn't work.
Nov 21 '05 #5

P: n/a
I think I understand you. You need to pass a non-null date value to the
dataset when the datetimepicker has not been selected. This is indeed the
way I would do it (and have done it).

But without any code, there is much that all of us would be speculating
upon. How are the datetimepicker values being passed to the dataset? What
causes the the update to be applied to the backend database?

Fundamentally, the answer is the same however you are coding it -- you
either need to pass a non-null Date value (if Today.Date is acceptable), or
you need to protect for null being passed (another way of doing it).

To get a better answer, you will have to show the code snippet.

"Clamara" <Cl*****@discussions.microsoft.com> wrote in message
news:01**********************************@microsof t.com...
I think you misunderstand me...

PLEASE TRY THIS PLEASE TRY THIS PLEASE TRY THIS PLEASE TRY THIS

try this with vb.net 2003

create with the dataform wizard a form that bind to a simple sql table
with
productID and dateofproduct (datetime and not nullable).
If you show the form the load event put as dateofproduct default the
today's
date but if you try to update the dataset without touch the datetimepicker
control the dataset reject to update cause the datetimepicker value is
null.
While if I touch the datetimepicker control and i choose a date the update
works.

My problem
is, if the user does not choose a value from the DateTimePicker (because
using the default is good enough) the update doesn't works.

I haved try to set datetimepicker.value = now() during the load event but
it
doesn't work.

Nov 21 '05 #6

P: n/a
Hi,

http://www.windowsforms.net/Forums/S...=41&PostID=948

Ken
----------------
"Clamara" <Cl*****@discussions.microsoft.com> wrote in message
news:C6**********************************@microsof t.com...
When adding a new record from my form, I pre-set my DateTimePicker's value
to
System.DateTime.Today
Since the "Today" value is used most of the time, the user doesn't need to
select a date from the DateTimePicker, since the default is shown. My
problem
is, if the user does not choose a value from the DateTimePicker (because
using the default is good enough), then during database update, the date
value is not saved to the database; while if user choose another value other
then the default, the value can be saved to the database successfully. Is
there a way to ensure the default value can be saved to the database?
Nov 21 '05 #7

P: n/a
thank you ken, I have try the link that you give me....from this i search for
other code and i find this link
http://www.dotnet247.com/247referenc...ck_313513.aspx

this one it's very cool

thank you

"Ken Tucker [MVP]" wrote:
Hi,

http://www.windowsforms.net/Forums/S...=41&PostID=948

Ken
----------------
"Clamara" <Cl*****@discussions.microsoft.com> wrote in message
news:C6**********************************@microsof t.com...
When adding a new record from my form, I pre-set my DateTimePicker's value
to
System.DateTime.Today
Since the "Today" value is used most of the time, the user doesn't need to
select a date from the DateTimePicker, since the default is shown. My
problem
is, if the user does not choose a value from the DateTimePicker (because
using the default is good enough), then during database update, the date
value is not saved to the database; while if user choose another value other
then the default, the value can be saved to the database successfully. Is
there a way to ensure the default value can be saved to the database?

Nov 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.