473,397 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

datetimepicker dataset

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
7 6176
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gary Miller | last post by:
I have a DateTimePicker field and it is has a DataBinding to my dataset through the Text parameter. Why is it that if I do not choose a date that the information does not get propagated to the...
9
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it...
0
by: Uchiha Jax | last post by:
When using a strongly typed dataset (generated from the Visual Studio IDE from an XSD file) and databinding I get a really odd error when binding to both a combox and a datetimepicker. I bind...
2
by: LC | last post by:
I am on the learn C#. Net in 695 day program. I am just trying to learn stuff. I have MSAccess database with 1 table called 'ParmDate' with 1 column called 'ParmDate' which represents a date for...
6
by: eye5600 | last post by:
Is there a cure for the problems using databinding with a DateTimePicker? I find that a) sometimes it works, sometimes it doesn't, and b) it fails silently causing all databinding on the DataSet...
4
by: Jacek Jurkowski | last post by:
.... the minimum date of DateTimePicker is 1753-01-01. How to make DateTime to do not show nothing in its text if this date is the value? I have a form with a field LastLogonDate. If user hasn't...
2
by: Austin T | last post by:
I have a datetimepicker called say mydteTimePicker and it is bound to a dataset. However the the dataset value is null the datetimepicker displays today's date as the default. I would like it to...
3
by: Charlie | last post by:
In the top portion of the DateTimePicker, where the value of the date is displayed, how can I detect whether the month or day or year is currently focused, or, if ShowCheckBox = True, whether the...
2
by: mafandon | last post by:
This example deals with a datetimepicker Date of Birth concept for a windows form in VB 2005. Simply put, if a user wants to enter the MM/DD/YYYY using the number pad, how can I advance the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.