字符串为空怎么处理?在线等

stephenzhou1234 2003-05-17 02:58:27
字符串为空怎么处理?
比如我用RS访问数据库,返回一个RS但有可能为空
比如:
sql1="select Nation from nation_category where Nation_ID=‘A’"
Set typelie1 = Server.CreateObject("ADODB.Recordset")
typelie1.open sql1,conn,1.1

NATION中没有数据录入,所以返回应该为空
但没有判断空的函数

A=typelie1("Nation")
我无法判断A是否为空

大家有没有办法呀
在线等
...全文
84 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
stephenzhou1234 2003-05-17
  • 打赏
  • 举报
回复
cmsoft(韦小宝是我的老乡.net)
你这找还行,但我需要处理N条判断
你不会让我做N个IF吧!
简单的办法
最好函数能处理
cmsoft 2003-05-17
  • 打赏
  • 举报
回复
if rs.eof then
没有记录
else
A=typelie1("Nation")

if A&"cmsoft"="cmsoft" then
A为空
else
不为空
end if

end if

stephenzhou1234 2003-05-17
  • 打赏
  • 举报
回复
现在情况是数据库如果不录入的话该字段不会置NULL
它什么也没有
清楚吗?
如果A字段没有数据录入该字段就什么也没有,没有NULL。
所以ISNULL这类的函数没有用
cmsoft 2003-05-17
  • 打赏
  • 举报
回复
if rs.eof then
没有记录
else
有记录
a=Rs("……")
end if
dychen 2003-05-17
  • 打赏
  • 举报
回复
typelie1.open sql1,conn,3,1执行语句
然后在用上述方法判断
if typelie1.eof then
end if

if typelie1.recordcount=0 then
end if
注意这里是vbscript脚本
应该是可以,我用了不知多少次了
caoshangfei 2003-05-17
  • 打赏
  • 举报
回复
用if rs.eof and rs.bof then
end if也会出错???不可能。。。
stephenzhou1234 2003-05-17
  • 打赏
  • 举报
回复
现在RS已经为空
没有任何数据
但我需要执行SELECT语句返回RS
如果RS没有信息我不能对RS进行任何操作
我也知道为什么
SonMeiKa 2003-05-17
  • 打赏
  • 举报
回复
我这样没出问题

dim i
i=0
do
i++
until rs.eof

if i=0 then
记录为空
end if
lsrzm 2003-05-17
  • 打赏
  • 举报
回复
sql1="select idnull(Nation,-1) nat from nation_category where Nation_ID=‘A’"
如果是为空的话则nat变成了-1,然后rs("nat")如果等于-1的话怎Nation为空
stephenzhou1234 2003-05-17
  • 打赏
  • 举报
回复
ISNULL()
LEN()
之类的函数完全没有用
连RS的东西也非法比如
rs().eof and rs.bof都非法
stephenzhou1234 2003-05-17
  • 打赏
  • 举报
回复
都没有用

因为RS已经什么都没有了
用光所有判断是否为空的函数 都没有用
这应该叫“真空”吧

现在只要没数据录入
我对RS进行任何操作都非法
veryhappy 2003-05-17
  • 打赏
  • 举报
回复
isEmpty(typeliel("Nation"))
ministry_bill 2003-05-17
  • 打赏
  • 举报
回复
if isnull(typelie1.fields("Nation")) then
...
end if
cmsoft 2003-05-17
  • 打赏
  • 举报
回复
A=typelie1("Nation")

if A&"cmsoft"="cmsoft" then
A为空
else
不为空
end if
ministry_bill 2003-05-17
  • 打赏
  • 举报
回复
sorry,
if rs.eof and rs.bof then
...
end if

or

if rs.recordcount=0 then
...
end if
roy66 2003-05-17
  • 打赏
  • 举报
回复
isnull
ministry_bill 2003-05-17
  • 打赏
  • 举报
回复
if rs.eof and rs.bof
...
end if

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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