2013-08-06 91 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

相关问题