2013-08-06 136 views
-1

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

+0

這是很多(格式不正確)的代碼 - 究竟是哪裏發生了問題? –

+0

*請*使用參數化SQL,而不是將值放入SQL字符串本身中... –

+0

我在這部分中有probelm start = combine(row.Cells(1).Value,row.Cells(2).Value) marche = combine(row.Cells(3).Value,row.Cells(4).Value) – Bichoua

回答

0

這是一個雙重問題;

你問媒體鏈接在這裏:manipulate DataGridView

我問你剔除非相關的東西,你也沒有做與以前的任何問題。

+0

謝謝你,我拿出你看到的東西! ,對於最後一個問題,我問如何操縱dataGridView,如果你有任何提議,我會在這個操作中遇到問題 – Bichoua

相關問題