50分求助!!!!先帮忙解决的全得~~~~~~~

penghb81 2004-12-03 09:20:08
现有一表TABLE,TABLE中有字段ID,NAME。
rs.open "select name from table",db,1,1
有一值WANG,怎么判断WANG是否在RS中呢。是的话就执行语句1,否的话就执行语句2。
请给出代码,谢谢。数据库是SQL。
...全文
73 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Mars.CN 2004-12-03
  • 打赏
  • 举报
回复
rs.open "select name from table where name = 'wang'",db,1,1
if rs.RecordCount>0 then
msgbox "找到!"
else
msgbox "没找到!"
endif
lxgmag 2004-12-03
  • 打赏
  • 举报
回复
利用RS的FILTER方法,检索RECORDSET 数据集,若有的eof()为FALSE,否则就为TRUE,具体代码如下:
rs.movefirst
rs.filter="name='wang'"
if rs.eof()
语句2
else
语句1
end if
Abyss-Xu 2004-12-03
  • 打赏
  • 举报
回复
只能是用SQL 找到name 字段中有wang 这行后
来判断是否有没有了
上面的说的对
hj5182001 2004-12-03
  • 打赏
  • 举报
回复
rs.open "select name from table where name = 'wang'",db,1,1
if rs.RecordCount>0 then
'存在
else
'不存在
endif
starsoulxp 2004-12-03
  • 打赏
  • 举报
回复
楼上的正解
jilong4 2004-12-03
  • 打赏
  • 举报
回复
rs.open "select name from table where name='Wang'",db,1,1
if rs.eof() then
msgbox("没王")
else
...
end if
wenhongL 2004-12-03
  • 打赏
  • 举报
回复
rs.open "select name from table where name like 'wang'",db,1,1
if not rs.eof and not rs.bof then
'存在
endif

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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