如果有人可以幫助我這個我的代碼,並且將類型'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