以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  【求助】错误提示  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=97855)

--  作者:10059
--  发布时间:2017/3/20 8:51:00
--  【求助】错误提示
老师,请问我表中的“sex“列是字符型的,为什么还会有下面的错误提示呢??

详细错误信息:
调用的目标发生了异常。
从字符串“女”到类型“Double”的转换无效。
输入字符串的格式不正确。

代码如下:
If e.datacol.name = "sex" then
        If e.DataRow.Isnull("sex") = True Then
            e.DataRow("sex") = Nothing
        Else 
            If e.newvalue = 1 Then
                e.DataRow("sex") = "男"
            Else
                e.DataRow("sex") = "女"
            End If
        End If
End If

--  作者:有点色
--  发布时间:2017/3/20 10:53:00
--  
If e.datacol.name = "sex" then
        If e.DataRow.Isnull("sex") = True Then
            e.DataRow("sex") = Nothing
        Else 
            If e.newvalue = "1" Then
                e.DataRow("sex") = "男"
            Else
                e.DataRow("sex") = "女"
            End If
        End If
End If