如果有人可以帮助我这个我的代码,并且将类型'TimeSpan'转换为'Date' 错误:类型'TimeSpan'到类型'Date'的转换是无效的.vb.net
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
错误:
型“时间跨度”的转换输入“日期”是无效的。
我想知道什么是错误的
注:在我的数据库,DateStartTasck是类型日期(SQL)以这种形式(YYYY-MM-DD),且TimeStartTasck的类型时(SQL)与此表格00:00:00
这是很多(格式不正确)的代码 - 究竟是哪里发生了问题? –
*请*使用参数化SQL,而不是将值放入SQL字符串本身中... –
我在这部分中有probelm start = combine(row.Cells(1).Value,row.Cells(2).Value) marche = combine(row.Cells(3).Value,row.Cells(4).Value) – Bichoua