Would appreciate assistance on the below.
I am using VB.NET and SQL Server.
I have a form with a datagridview, when the user clicks one of the rows (Header rows) on the datagridview the form shows the detail for the header in text boxes, comboboxes and datetimepickers allowing the user to edit the detail values and saving back to the database.
I am having trouble returning the times saved in my database to the datetimepickers, they default to the current system time and do not return the saved time in the Database:
I am using a datetimepicker format set to "Time" so the actual date is irrelevant, only the time.
I have tried the below in my Datagridview_CellContentClick event:
Dim dr As DataRowView = GetStoreMasterBindingSource.Current
WeekStartTimeDateTimePicker.Text = dr.Item("WeekStartTime").Value
But get the following error at runtime:
Public member 'Value' on type 'Timespan' not found.
I have also tried the following:
Dim dr As DataRowView = GetStoreMasterBindingSource.Current
WeekStartTimeDateTimePicker.Value = New DateTime(DateTime.Now.Year, DateTime.Now.Month,
DateTime.Now.Day, dr.Item("WeekStartTime").hour,
dr.Item("WeekStartTime").minute,
dr.Item("WeekStartTime").second)
But get the following error at runtime:
Public member 'hour' on type 'Timespan' not found.
My SQL datatype for this column is TIME.
Please assist me to set the time value of my datatimepicker to the value returned from the database?
Option Strict Onin your project properties and in your VS options, so it isOnby default for future projects. - jmcilhinney