◆各位兄弟,请进。这样判断数据库记录为空时,怎么不行?◆

cwm545 2004-05-11 10:12:07
是这样的,我想判断是否有这条记录。
如果有就存入变量ne,但下面的程序不行啊,帮我改一下了,谢谢!

Set rs = cn.Execute(sqla)
If rs.EOF Then
ne = 0
Else
ne = rs![name]
End If

因为当没有这条记录时,ne=rs![name]是会提示会空。
但我已经判断过了,如果为空就为0吗,各位UP下,谢谢!
...全文
146 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
hanhuole 2004-05-11
  • 打赏
  • 举报
回复
If rs.RecordCount<1 Then
是判断记录集中有没有记录,不是记录是否为空用
If isnull(rs![name]) Then
cwm545 2004-05-11
  • 打赏
  • 举报
回复
TO 明月高楼休独倚,酒入愁肠,化作相思泪!

Set rs = cn.Execute(sqla)
If rs.RecordCount<1 Then
ne = 0
Else
ne=rs![name]
End If

这个好像不行哟!
cwm545 2004-05-11
  • 打赏
  • 举报
回复
TO 明月高楼休独倚,酒入愁肠,化作相思泪!

几时变成一个星了,上次不是还是五个三角吗?谢谢你了,还有楼上的兄弟们。
wumy_ld 2004-05-11
  • 打赏
  • 举报
回复
Set rs = cn.Execute(sqla)
If rs.RecordCount<1 Then
ne = 0
Else
ne=rs![name]
End If

or

Set rs = cn.Execute(sqla)
If isnull(rs![name]) Then
ne = 0
Else
ne=rs![name]
End If
griefforyou 2004-05-11
  • 打赏
  • 举报
回复
Set rs = cn.Execute(sqla)
If rs.EOF Then
ne = 0
Else
if not isNull(rs![name]) then
ne=rs![name]
else
ne=0
end if
End If
griefforyou 2004-05-11
  • 打赏
  • 举报
回复
ne = "" & rs![name]
cwm545 2004-05-11
  • 打赏
  • 举报
回复
等等,在SQL中,我是设置数字的类型。我加过了,不行的。
饮水需思源 2004-05-11
  • 打赏
  • 举报
回复
Set rs = cn.Execute(sqla)
If rs.EOF Then
ne = 0
Else
ne = rs![name] & "" '加上一个空值字叙述者符,即使值为NULL也不会出错
End If
cwm545 2004-05-11
  • 打赏
  • 举报
回复
无效使用unll
谢谢!
titan90 2004-05-11
  • 打赏
  • 举报
回复
出现什么问题
cwm545 2004-05-11
  • 打赏
  • 举报
回复
呵呵,忘了结贴!
谢谢你们了!
99414325ALe 2004-05-11
  • 打赏
  • 举报
回复
Set rs = cn.Execute(sqla)
If rs.EOF Then
ne = 0
Else
ne = val(rs![name] & "") '加上一个空值字叙述者符,即使值为NULL也不会出错
End If
xucome 2004-05-11
  • 打赏
  • 举报
回复
Set rs = cn.Execute(sqla)
If rs.RecordCount<1 Then
ne = 0
Else
ne=rs![name]
End If
我调试了一下但为什么rs.RecordCountp这句会出错
operation is not allowed when the object is close
这是什么原因呢??请指教

1,217

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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