哈雷883极速多少:asp中关于NULL的问题!拜求!!!

来源:百度文库 编辑:高考问答 时间:2024/05/08 23:26:47
我的数据库中一条记录中的一个字段名 reply什么值都没有负过。我用
if rs("reply")="" or rs("reply")=null then

response.redirect "error.asp?info=对不起,您没有权限浏览此页!"
end if。但是if语句没有执行。但是我用if isnull(rs("replyname"))=true then 却执行了!怎么回事呀?既然值为空,为什么rs("reply")=null 不对呢???
天,你们回答的什么呀!我都找到答案了!
http://zhidao.baidu.com/question/2189397.html
我的数据库中的字段是null.所以任何表达式=null都是返回FALSE。所以才会出现我的情况,判断等于NULL,只有用ISNULL()来判断,所以以后往数据库中写纪录,最好不要有空!""之不过是空字符串的意思!
应该用if rs("reply")="" or isnull(rs("reply"))=true then

你那样写当然是不对了,应该写成这样
if rs("reply")="" or rs("reply")=null then
response.redirect "error.asp"
end if

或者
if rs("reply")="" or rs("reply")=null then
response.write "对不起,您没有权限浏览此页!"
end if

写反了,应该写成:

if rs("reply")=null or rs("reply")="" then

if rs("reply")="" then

response.redirect "error.asp?info=对不起,您没有权限浏览此页!"

end if
去掉 rs("reply")=null