稍有一些信心,却被莫名其妙的错误提示搞的焦头烂额,在运行这个任务的时候却有出现这样的提示:
下面是程序:
出现问题的时候是数据表dt1已经运行到最后一行数据 12705#,结果一旦运行到“dr1("ScanOutTime") ”就出现上述问题。
通过检查,ScanOutTime,确实是Date类型
通过dr1("WO") 可以判断该行确实存在,其结果如下,经验证,该工单号信息正常
关键是通过检查 dr1(“ScanOutTime“),其值为‘00:00:00’,显示数据行是成立的。
我的疑问是既然目标行存在,且不同列是存在数据的,但为何就显示找不到实例:
程序:
'补充扫描数据写入生产问题跟踪表 ProductionIssue_FromAdditionalWO
If User.Type = UserTypeEnum.Developer Then
'SystemReady = False
If Not DataTables.Contains("AddtionalWOData") Then
DataTables.Load("AddtionalWOData")
End If
If Not DataTables.Contains("ProductionIssue") Then
DataTables.Load("ProductionIssue")
End If
Dim dt1 As DataTable = DataTables("AddtionalWOData")
Dim dt2 As DataTable = DataTables("ProductionIssue")
Dim i As Integer
Dim i1 As Integer
Dim i2 As Integer
If Not DataTables.Contains("ProductDeveloper") Then
DataTables.Load("ProductDeveloper")
End If
Dim dt3 As DataTable = DataTables("ProductDeveloper")
Dim Filter As String
Try
For Each dr1 As DataRow In dt1.DataRows
i2 = i2 + 1
If Not dr1.IsNull("问题描述") Then
If dr1.IsNull("编号") = False Then
Filter = "[交易号]='" & dr1("编号") & "'"
'Output.Show(Filter)
Dim dr2 As DataRow = dt2.Find(Filter)
If dr2 Is Nothing = True Then 'AddNew
i = i + 1
Output.Show(i & "," & dr1("WO"))
Dim dr2n As DataRow = dt2.AddNew
dr2n("DataResource") = dr1("来源")
dr2n("Date") = dr1("发现时间")
dr2n("ResID") = dr1("ResID") 'ResID
dr2n("PartNumber") = dr1("PartID") 'PartID
dr2n("WO") = dr1("WO") 'WO
dr2n("OP") = dr1("OP") 'OP
dr2n("WOQTY") = dr1("Qty") 'WoQty
dr2n("Description") = dr1("问题描述") 'Des
dr2n("IssueType问题种类") = dr1("问题类别") 'IssueType
'dr2n("Affect后果") = dr1("Question_Affect") 'Affect
'dr2n("DelayHrs延误小时") = dr1("PastDays") '延误小时
dr2n("Res责任部门") = dr1("责任班组") 'Responser=>责任部门
'dr2n("Person责任人") = dr1("Question_Dealer") '责任人
Dim Fl As String = "[PartID]='" & dr1("PartID") & "'"
If dt3.Find(fl) IsNot Nothing Then
Dim dr3 As DataRow = dt3.Find(fl)
If dr3 IsNot Nothing Then
dr2n("QE") = dr3("QE") 'QE
dr2n("ME") = dr3("ME") 'ME
End If
End If
dr2n("Reviser") = dr1("发现者") '登记人
dr2n("交易号") = dr1("编号") '交易号
dr2n("SolvedDate解决日期") = dr1("ScanOutTime") '
If Isdate(dr2n("SolvedDate解决日期")) Then
Dim tp As TimeSpan
tp = dr2n("SolvedDate解决日期") - dr2n("Date")
dr2n("WholeTime全程天数") = Round2( tp.TotalDays, 2)
End If
Else '已存在,则根据变更内容进行重新写入
If dr2("Description") <> dr1("问题描述") Then
dr2("Description") = dr1("问题描述") 'Des
End If
If dr2("IssueType问题种类") <> dr1("问题类别") Then
dr2("IssueType问题种类") = dr1("问题类别") 'IssueType
End If
If dr2("Res责任部门") <> dr1("责任班组") Then
dr2("Res责任部门") = dr1("责任班组") 'Responser=>责任部门
End If
If I2 = 12075 Then
MessageBox.Show( dr1("wo"))
If dr1("WO") = "IWO87363/1" Then
messagebox.Show(dr1("ScanOutTime"))
End If
If dr1("ScanOutTime") > #01-01-2023# Then
‘此处出现错误提示’
If dr2("SolvedDate解决日期") <> dr1("ScanOutTime") Then
dr2("SolvedDate解决日期") = dr1("ScanOutTime") '
If Isdate(dr2("SolvedDate解决日期")) Then
Dim tp As TimeSpan
If dr2.IsNull("SolvedDate解决日期") = False And dr2.IsNull("Date") = False Then
tp = dr2("SolvedDate解决日期") - dr2("Date")
dr2("WholeTime全程天数") = tp.TotalDays
Else
dr2("WholeTime全程天数") = Nothing
End If
i = i + 1
Output.Show(i & "," & dr1("WO"))
End If
End If
End If
End If
End If
End If
End If
Next
Catch ex As Exception '如果出错
msgbox(ex.message)
MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error)
GoTo 1
End Try
1:
If i > 0 Then
dt2.Save
End If
Dim dr As DataRow = DataTables("Data").Find("文件更新_文件名 = '" & "ProductionIssue_FromAdditionnalWO'")
dr("文件更新_时间") = Date.Now
SystemReady = True
End If
请大伙儿帮忙看一下,我实在是么有办法了,谢谢!