set rst=server.CreateObject("ADODB.RecordSet")
rst.open "select * from pictype where typeid="&typeid&"",conn,1,3
if not rs.eof then
call showms("不为空")
end if
上面一段语句是得出了不为空的代码,我想知道得出为空的代码是什么?
...全文
1215打赏收藏
如何判断一个字段为空?
set rst=server.CreateObject("ADODB.RecordSet") rst.open "select * from pictype where typeid="&typeid&"",conn,1,3 if not rs.eof then call showms("不为空") end if 上面一段语句是得出了不为空的代码,我想知道得出为空的代码是什么?
一般我们说的字段为空不是真正的“空”,而是以下两种情况:
1、初始化了该字段,但是写入的是空字符串,此时数据库会自动用空格填满该字段;
if Trim(字段)=""可判断出该字段为空
2、未初始化该字段(该字段允许为空);
if IsNull(字段)可以判断出该字段为空
【结论】:所以判断字段是否为空的方法应从上述两点着手:
if IsNull(字段) or Trim(字段)="" 就可判断出为空的字段