SQL Server中判断为是否空的奇怪现象????????

glwdpy 2003-12-27 04:26:33
我在ASP中判断SQL Server中的某个值是否空,发现一个很令人不解的问题!!
sql="select * from tables where username='"& username &"'"
set rs=server.createobject("ADODB.Recordset")
rs.open sql,conn,1,3
为什么我判断其中某个值为空的时候会出现下面的现象呢?
if rs("testpd")="" then
response.write "aaa"
else
response.write "bbb"
end if

不管我上面的testpd字段的值是否为<NULL>(数据库里的显示),上面都是输出bbb
我用response.write rs("testpd")想输出这个字段的值到底是什么,结果它输出又是为空!!

我把代码改成下面的样子:
if trim(rs("testpd"))="<NULL>" then
response.write "aaa"
else
response.write "bbb"
end if
不管什么情况输出还是bbb
于是我又改:
if trim(rs("testpd"))=empty then
response.write "aaa"
else
response.write "bbb"
end if
输出结果一样!
请问各位大哥,这个是怎么回事,我怎么样才可以判断呢????
...全文
53 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
glwdpy 2003-12-27
  • 打赏
  • 举报
回复
谢谢了
解决了
是邹建大哥那种形式

dlpseeyou(豆子)兄台,你那样不能判断的!!
zjcxc 元老 2003-12-27
  • 打赏
  • 举报
回复
'或
if isnull(rs("testpd")) or rs("testpd")="" then
response.write "aaa"
else
response.write "bbb"
end if
zjcxc 元老 2003-12-27
  • 打赏
  • 举报
回复
'asp中这样处理
if rs("testpd")+""="" then
response.write "aaa"
else
response.write "bbb"
end if
tomhuang 2003-12-27
  • 打赏
  • 举报
回复
要用is null或is not null.
dlpseeyou 2003-12-27
  • 打赏
  • 举报
回复
if rs("testpd")=""or rs("testpd") is null then
response.write "aaa"
else
response.write "bbb"
end if

34,838

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧