我在数据库(sqlServer2000)中的m表建两个字段a,b(varchar型,允许为空),把开表在a字段里随便写入几个字如ttt,保存。这时可以看到b字段里的为<NULL>标志。可是为什么判断不出<NULL>这个标志来?
程序如下:
为什么显示不出hello这个字符串?
<%
Set rs = cn.Execute("select a,b from m where a=ttt")
if rs("b") = null or rs("b") = empty or rs("b") = "" then
Response.Write "hello"
end if
%>
这是不能直接判断的,但是可以通过这种方法来得到它是否是null字段
:
rs("b") +""==null
if isnull(rs("b"))
select * from xxx where xxx is null.
<%
Set rs = cn.Execute("select a,b from m where a=ttt")
if rs("b") & "a" = "a" then
Response.Write "hello"
end if
%>