Hi!
I have a table that has StartTime and EndTime columns both assigned with Time datatype (im not sure if this is right)
I am pulling the records up to be displayed in a ListView Control in my VB.NET program. However it gives me an error that Timespan cannot be converted to string. Here is my code:
Dim getShifts As String = "Select ShiftID, StartTime, EndTime from tblshift"
cmd = New MySqlCommand(getShifts, con) 'con is the connection
dr = cmd.ExecuteReader
lvShift.Items.Clear()
While dr.Read
Dim lv As ListViewItem = lvShift.Items.Add(dr("ShiftID"))
Dim dt, dt2 As DateTime
dt = Convert.ToDateTime(dr(1))
dt2 = Convert.ToDateTime(dr(2))
With lv
.SubItems.Add(dt)
.SubItems.Add(dt2)
End With
End While
dr.Close()
please help me with this. alternative solutions will be appreciated. thank you guys! and God bless!!
I have a table that has StartTime and EndTime columns both assigned with Time datatype (im not sure if this is right)
I am pulling the records up to be displayed in a ListView Control in my VB.NET program. However it gives me an error that Timespan cannot be converted to string. Here is my code:
Quote:
Dim getShifts As String = "Select ShiftID, StartTime, EndTime from tblshift"
cmd = New MySqlCommand(getShifts, con) 'con is the connection
dr = cmd.ExecuteReader
lvShift.Items.Clear()
While dr.Read
Dim lv As ListViewItem = lvShift.Items.Add(dr("ShiftID"))
Dim dt, dt2 As DateTime
dt = Convert.ToDateTime(dr(1))
dt2 = Convert.ToDateTime(dr(2))
With lv
.SubItems.Add(dt)
.SubItems.Add(dt2)
End With
End While
dr.Close()