473,747 Members | 2,298 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6214
If Then

Else

End If

"Clamara" <Cl*****@discus sions.microsoft .com> wrote in message
news:C6******** *************** ***********@mic rosoft.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*****@discus sions.microsoft .com> wrote in message
news:C6******** *************** ***********@mic rosoft.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*****@discus sions.microsoft .com> wrote in message
news:08******** *************** ***********@mic rosoft.com...
it's a joke???

"Earl" wrote:
If Then

Else

End If

"Clamara" <Cl*****@discus sions.microsoft .com> wrote in message
news:C6******** *************** ***********@mic rosoft.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*****@discus sions.microsoft .com> wrote in message
news:01******** *************** ***********@mic rosoft.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*****@discus sions.microsoft .com> wrote in message
news:C6******** *************** ***********@mic rosoft.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*****@discus sions.microsoft .com> wrote in message
news:C6******** *************** ***********@mic rosoft.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
301
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 database? The field comes up with today's date in it and I do not fell it necessary to choose a date if today's date is OK. What am I doing wrong?
9
3974
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 will not set the value of the control and will leave the checked status of the checkbox to false when a user selects a new date. this works fine when using the control on a win2k machine but if we use it on a win XP box and call
0
2016
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 like the following: //// tDs is the strongly typed dataset, //// tDs.TheTask returns a strongly typed row from one of the tables. /// GetBindingTaskTypes() returns the types I want to use as a datasource in an arraylist.
2
2909
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 which the rest of the processing will be based. I have a Windows Form with a DateTimePicker that is bound to this MSAccess database and 'ParmDate' table and column. I have a button on the form that when clicked will update the dataset. I have a...
6
6735
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 to fail with a error message. Help!
4
5682
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 logon yet this date should be empty but when binding a property to the DateTimePicker value it always shows value parsed prom property which is 1753-01-01. How to make an "empty" or "not set" date bindable to a value property of DateTimePicker?
2
5460
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 display a blank if there is no date. Any ideas on how to do this Thank yo Austin
3
6391
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 checkbox is focused?
2
1728
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 cursor to the DD and then the YYYY without needing to use the "/" key?? So the keystrokes look like "07041978" versus doing "07/04/1978". Secondly - if we don't know the D.O.B. at the time of input, we'd like to make update the dataset with a...
0
8818
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9355
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8234
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6790
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6069
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4589
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4860
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3296
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2203
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.