以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  从字符串""到“double“的转换无效,这是什么错误  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=74959)

--  作者:zhuzhi
--  发布时间:2015/9/23 14:35:00
--  从字符串""到“double“的转换无效,这是什么错误
老师您好!我的代码运行出现如下报错:

此主题相关图片如下:qq截图20150923142607.jpg
按此在新窗口浏览图片

请问这可能是什么原因呢?
我的代码原本是:

If e.DataCol.Name = "结果" Then

    Dim dr As DataRow =DataTables("总库").Find("工号 = \'" & e.DataRow("工号") & "\'")

    If dr IsNot Nothing Then

        If e.NewValue = "离职" Then

            dr("状态")="离职"

        Else If e.NewValue = "病假" Then

            dr("状态")="病假"

        End If

End If

   End If

运行是没有问题的。但是我需要加上调职这一个变动,涉及到数据的引入,所以要定义另一张工作表,我尝试做了下:

For Each dr1 As DataRow In DataTables("总表").DataRows

If e.DataCol.Name = "结果" Then

    Dim dr As DataRow =DataTables("总库").Find("工号 = \'" & e.DataRow("工号") & "\'")

    If dr IsNot Nothing Then

        If e.NewValue = "离职" Then

            dr("状态")="离职"

        Else If e.NewValue = "病假" Then

            dr("学籍状态")="病假"

        Else If e.NewValue = "调动" Then

            dr("部门") = dr1("部门")

        End If

End If

    End If

Next


所以就出现如上错误。


请教老师们,这主要是因为什么呢?怎么解决?


十分感谢!


--  作者:大红袍
--  发布时间:2015/9/23 14:41:00
--  

直接这样写

 

If e.DataCol.Name = "结果" AndAlso e.DataRow.isnull("工号") = False Then
   
    Dim dr As DataRow =DataTables("总库").Find("工号 = \'" & e.DataRow("工号") & "\'")
   
    If dr IsNot Nothing Then
       
        If e.NewValue = "离职" Then
           
            dr("状态")="离职"
           
        Else If e.NewValue = "病假" Then
           
            dr("学籍状态")="病假"
           
        Else If e.NewValue = "调动" Then
           
            dr("部门") = e.DataRow("部门")
           
        End If
       
    End If
   
End If

 


--  作者:ww7686
--  发布时间:2016/11/7 22:41:00
--  eqreqre
werewr