473,670 Members | 2,295 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

date time picker binding bug

hi, I have this problem with the date time picker, when I bind the control
to data table and add new record, it is ok, however, if I delete all records
via a button using the
me.bindingconte xt(datatable).r emoveat(me.bind ingcontext(data Table).position )
statement, it always throw the following error ..

A first chance exception of type 'System.Argumen tException' occurred in
system.dll

Additional information: '1/1/0001 12:00:00 AM' is not a valid value for
'Value'. 'Value' should be between 'MinDate' and 'MaxDate'.

microsoft KB
http://support.microsoft.com/default...US;Q313513#kb5

did acknowledge this problem but it doesn't seem to solve this situation.

To simulate this problem, just create a table with a datetime field and bind
it to a window form date time picker control, then have 2 buttons, one to
add records via Me.BindingConte xt(dataTable).A ddNew() ... and another to
delete the record via above mentioned code, when you are deleting the last
record, this error will popup even you include the format & parse codes as
recommend by MS. The problem here is that it doesn't even go to the
format/parse when before it throws this error..

Can anyone please help!

Thank in advance

Hanbert
Nov 21 '05 #1
5 5894
Johnaton,

It seems for me natural, when there is no date it gives this date so why
don't you check before the remove if the datatable.rows. count = 1 and than
remove the binding before.

That is what I would do and than when that does it, not look at if anymore

And test in an add of course if the rowtable = 1 and than add the binding
(it should than be empty).

Just my thought,

Cor
Nov 21 '05 #2
Hi Cor,

Thank for your reply, I have illustrated the problem with a simple example,
however, the application involved many date and other fields which made this
option not very viable. moreover, I'll need to add codes to put the binding
back again if user click the ADD button...and there is not single command
like the clear all bindings for the form, each controls must be unbind
individually and bind again individually...

What I can't understand is why the format & parse event handlers don't work
as suggested by Microsoft in this situation. where there are records, the
format & parse codes run. But upon deleting the last record, so how, it just
don't activate these codes.???

Can some experts out there enlighten me on this? Or point to any articles to
overcome this or even how to re-write (extent) this control .

Thank in advance .



"Cor Ligthert" <no************ @planet.nl> wrote in message
news:es******** ******@TK2MSFTN GP12.phx.gbl...
Johnaton,

It seems for me natural, when there is no date it gives this date so why
don't you check before the remove if the datatable.rows. count = 1 and than
remove the binding before.

That is what I would do and than when that does it, not look at if
anymore

And test in an add of course if the rowtable = 1 and than add the binding
(it should than be empty).

Just my thought,

Cor

Nov 21 '05 #3
Johnaton,

There was something strange in your message. However I took it as you wrote.
Now I have made a little test for it, and in my opinion is there no
exception throwed.

\\\
Dim dt As New DataTable
Private Sub Form4_Load(ByVa l sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
dt.Columns.Add( "mydate", GetType(System. DateTime))
For i As Integer = 0 To 10
dt.Rows.Add(dt. NewRow)
dt.Rows(i)(0) = Now.AddDays(-i)
Next
Me.DateTimePick er1.DataBinding s.Add("Value", dt, "mydate")
BindingContext( dt).Position = 10
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button1.Click
If dt.Rows.Count > 0 Then
dt.Rows.RemoveA t(BindingContex t(dt).Position)
Else
MessageBox.Show ("there are no more rows to remove")
End If
End Sub
///

So what do we do wrong?

Cor
Nov 21 '05 #4
Hi Cor,

Thank again for the reply .. don't understand what you mean by strange ...
I pasted your codes .... the exception error did throw ... don't it happen
on yours???

when I click the button1 on the 10th time ... ie. when count = 1 and after
it deleted the very last record, that exception message was thrown .... I
would be very interested to know if it doesn't happen on yours ..

that is what I mean, unless I write
If dt.Rows.Count = 1 Then
...whole chunk of codes to do unbinding ...
else
dt.Rows.RemoveA t(BindingContex t(dt).Position)
end if
..... and some where must check again to bind all controls again ..

Thank & will be interested to hear from you on the above ..

"Cor Ligthert" <no************ @planet.nl> wrote in message
news:%2******** *******@TK2MSFT NGP12.phx.gbl.. .
Johnaton,

There was something strange in your message. However I took it as you
wrote.
Now I have made a little test for it, and in my opinion is there no
exception throwed.

\\\
Dim dt As New DataTable
Private Sub Form4_Load(ByVa l sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
dt.Columns.Add( "mydate", GetType(System. DateTime))
For i As Integer = 0 To 10
dt.Rows.Add(dt. NewRow)
dt.Rows(i)(0) = Now.AddDays(-i)
Next
Me.DateTimePick er1.DataBinding s.Add("Value", dt, "mydate")
BindingContext( dt).Position = 10
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button1.Click
If dt.Rows.Count > 0 Then
dt.Rows.RemoveA t(BindingContex t(dt).Position)
Else
MessageBox.Show ("there are no more rows to remove")
End If
End Sub
///

So what do we do wrong?

Cor

Nov 21 '05 #5
Johnaton,

When it was thrown I would have told you, the messagebox is showed.

Mayby it is in the SP1 of the framework.

Cor
Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
7096
by: Adrian Parker | last post by:
Hi. I have a date time picker in my program which uses ADO to read from an Access database. It works perfectly, unless the database is empty (no records) when opened. When you try to open an empty database, the date time picker returns error 545. Any attempts to progmatically add new records after the empty database has been opened returns, or to use the DTP and set a new date for those added records, "Field not updateable, Bound...
3
5238
by: TD | last post by:
This code doesn't work. Every posting I can find suggests that it should. If TypeOf controlname Is DTPicker then do something here End If I am using the Date Time Picker control and wish to use TypeOf to determine if the controlname is indeed a Date Time Picker control.
7
10768
by: XmlAdoNewbie | last post by:
Hi All, I am wondering if it is possible to allow nulls or empty strings when it comes to the datetimepicker control. I have an app with a few datetimepickers on it and there are some instances when i don't want a date to show at all but the datetimepickers always have at least todays date in it so when i go to press the save button on my app there is always a date stored in the retrieved field. Is there a way to say "hey i don't want a...
2
3949
by: Need Helps | last post by:
The example given in msdn.com on how to create a Date Time Picker involves using the CreateWindowEx function. However, I created a dialog box using the graphical interface, and then used the graphical interface to add a Date Time Picker control to it. The only problem is, I don't know how to do anything with the Date Time Picker, like access the date selected within the control. All I have is the ID, which in my code is IDC_DATETIMEPICKER1. ...
4
2665
by: Michael Turner | last post by:
Hi Guys I have two DateTime pickers one shows the Date and the other the time, this is a requirement of the solution. The problem I have is that when the time is saved to the sql database into a datetime field it uses the default date which is a problem when I try to sort, what I wanted to know is there a way for me to set the date in the time picker to the date in the date picker? Any help greatly appreciated.
7
6752
by: Hardik Shah | last post by:
Hi there i'm trying to bind a checkbox and some date time picker fields to a dataset. this is wat i have tried for the check box but it doesnt seen to work chkObservation.DataBindings.Add("text", dsChildData, "Child.ChildObservation") SO how would i go about binding this?
2
2410
by: Darhl Thomason | last post by:
I'm converting my Access 2003 VBA app. I have a number of date fields in my db that I want to use the date/time picker control with, but if there is no entry in my database, I want the date/time picker to show no date. Right now the first time it shows a blank date record, it inserts today's date. But as I move through the db and it finds a date in that field, the next time it finds a blank data record, it uses the last one as the...
4
4868
by: Michel Posseth [MCP] | last post by:
I have a problem with the date time picker validate event wich i believe is a bug How to reproduce : throw on a form a date time picker control and a textbox control select the validating event of the control and add this code
0
2840
by: fredloh | last post by:
i have a tab control on my form. i then have several microsoft date and time picker control on the tab control. when i select a date on any of the date and time picker control, the result of the control's value is always 12:00:00 am instead of the date i selected even though the date displays correctly on the date and time picker control. the controls are unbound. why is this? i also have another identical form where the date and...
0
8471
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8817
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...
1
8593
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8663
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7423
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...
0
4215
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
4396
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2804
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
2
1799
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.