如果有人可以帮助我解决我的代码和错误,我对类型“TimeSpan”到类型“Date”的转换有疑问:
Public Function combine(ByVal dateonly As DateTime, ByVal timeonly As DateTime)
date_Combine = DateTime.Parse(dateonly)
Time_Combine = DateTime.Parse(timeonly)
date_Combine.AddHours(Double.Parse(timeonly.Hour))
date_Combine.AddMinutes(Double.Parse(timeonly.Minute))
date_Combine.AddSeconds(Double.Parse(timeonly.Second))
Return date_Combine
End Function
For Each row As DataGridViewRow In DataGridView1.Rows
start = combine(row.Cells(1).Value, row.Cells(2).Value)
marche = combine(row.Cells(3).Value, row.Cells(4).Value)
diff = marche.Subtract(start).Hours
total += diff
Next
MessageBox.Show(total)
TextBox7.Text = total
错误 :
类型“TimeSpan”到类型“Date”的转换无效。
我想知道怎么了
注意:在我的数据库中,DateStartTasck 的类型为 Date(sql),格式为 (yyyy-MM-dd),而 TimeStartTasck 的类型为 Time (sql),格式为 00:00:00