|
|
I am developing a portion of an application that deals with settings reminders and alarms for personal notes. I am trying to insert from a formatted datetimepicker( formatted to show time only ) the time a user wants to get a reminder of something he/she wants. The column in the MySql database is of type 'Time'. I was never succesfull in entering and saving the data. Either I was getting validation problems not allowing me to exit the datetimepicker after I choose the time. To resolve this issues I just made 'false' the option 'causes validation'. Now the problem is that the time is not inserted getting problems saying that :
here is the code for savingSpecified cast is not valid.Couldn't store <01/01/1753 00:00:00> in ntime Column. Expected type is TimeSpan.
I have tried declaring as timespan with this code replacing the first two lines of the above codeCode:Dim xtime As DateTime = New DateTime xtime = Me.NtimeDateTimePicker.Value Dim result As DialogResult result = MessageBox.Show("Proceed with saving?", "LandWorx", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) If result = Windows.Forms.DialogResult.Yes Then Me.UsernotesBindingSource.EndEdit() Me.UsernotesTableAdapter.Update(Vrahdb.usernotes) For Each _control As Control In TabControl1.Controls() For Each _control1 As Control In _control.Controls() _control1.Enabled = False Next Next ElseIf result = Windows.Forms.DialogResult.No Then Me.Close() ElseIf result = Windows.Forms.DialogResult.Cancel Then For Each _control As Control In TabControl1.Controls() For Each _control1 As Control In _control.Controls() _control1.Enabled = False Next Next End If Me.Vrahdb.usernotes.Clear() Me.UsernotesTableAdapter.Fill(Vrahdb.usernotes) Me.UsernotesBindingSource.MoveLast() Dim pos As Integer = Me.UsernotesBindingSource.Position Vrahdb.usernotes.Rows(pos).Item("ntime") = xtime Me.UsernotesTableAdapter.Update(Vrahdb.usernotes)
This time it does not even insert a new row it just updates the last entry I have changing its time. This is strange as this happens only when I use the above two lines.Dim xtime As TimeSpan = New TimeSpan
xtime = Me.NtimeDateTimePicker.Value.TimeOfDay
Thanks for all the replies.
cheers
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks