以文本方式查看主题
- Foxtable(狐表) (http://foxtable.com/bbs/index.asp)
-- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2)
---- dr.SQLGetValue("姓名") 怎么判空值? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=130557)
|
-- 作者:donald0001
-- 发布时间:2019/1/25 11:06:00
-- dr.SQLGetValue("姓名") 怎么判空值?
请问,dr.SQLGetValue("姓名") 怎么判断空值,直接赋值或判断都出错。
|
-- 作者:有点甜
-- 发布时间:2019/1/25 12:35:00
--
1、执行代码,弹出什么?
Dim str = DataTables("表A").DataRows(1).SQLGetValue("第一列") msgbox(str.Gettype.name)
2、你直接赋值或者判断的代码怎么写的?试试改成
Dim str = DataTables("表A").DataRows(1).SQLGetValue("第一列") If str Is dbnull.value Then msgbox(1) End If
|
-- 作者:donald0001
-- 发布时间:2019/1/25 14:19:00
--
都无法运行过赋值语句
我的代码: Dim currentname As String Dim dr As DataRow = Tables("姓名表").Current.DataRow currentname = dr.SQLGetValue("姓名")
运行到第三句赋值就出错
|
-- 作者:donald0001
-- 发布时间:2019/1/25 14:21:00
-- 弹出窗口
此主题相关图片如下:无标题.png
|
-- 作者:有点甜
-- 发布时间:2019/1/25 14:23:00
--
Dim currentname As Object
Dim dr As DataRow = Tables("姓名表").Current.DataRow
currentname = dr.SQLGetValue("姓名")
If currentname Is dbnull.value Then msgbox(1) End If
|
-- 作者:donald0001
-- 发布时间:2019/1/25 14:32:00
--
第三句:currentname = dr.SQLGetValue("姓名")就过不去,弹出出错窗口。
|
-- 作者:有点甜
-- 发布时间:2019/1/25 14:40:00
--
Dim currentname As Object
Dim dr As DataRow = Tables("姓名表").Current.DataRow
currentname = dr.SQLGetValue("姓名")
If currentname Is dbnull.value Then msgbox(1) End If
|
-- 作者:有点甜
-- 发布时间:2019/1/25 14:40:00
--
或者
Dim dr As DataRow = Tables("姓名表").Current.DataRow
If dr.SQLGetValue("姓名") Is dbnull.value Then msgbox(1) End If
|
-- 作者:有点甜
-- 发布时间:2019/1/25 14:41:00
--
或者
Dim currentname As String
Dim dr As DataRow = Tables("姓名表").Current.DataRow
currentname = dr.SQLGetValue("姓名").toString
|
-- 作者:donald0001
-- 发布时间:2019/1/25 14:45:00
--
好了,十分感谢!知道了,变量不能定义成string。
|