急!怎么判断记录集rs中已经存在某学号(student表)?

hbuxiaoshe 2003-12-20 06:57:05
如题。
...全文
235 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
JoAiron 2003-12-21
  • 打赏
  • 举报
回复
rs.open "select count(*) from student where 學號='aaa'"
if not rs.eof then
if rs(0) =0 then


else

endif
endif

netbandit 2003-12-20
  • 打赏
  • 举报
回复
Up
simanh 2003-12-20
  • 打赏
  • 举报
回复
同意,用find()
XMLWeb 2003-12-20
  • 打赏
  • 举报
回复
同意网虫的做法
wangchong 2003-12-20
  • 打赏
  • 举报
回复
楼主的意思可能是已经用的SELECT 把数据从数据库中取出来了。再着某条记录

两种方法:

1,用 Find
rs.find("字段 = '数值'")
if not rs.eof then
存在
end if
2,用Filter
rs.filter("字段 = '数值'")
if not rs.eof then
存在
end if
sogno 2003-12-20
  • 打赏
  • 举报
回复
表名:student,学号字段名sid,要判断的学号是一个变量studentId,整型
ado记录集变量名rs

rs.filter = "sid = " & studentId '设置记录集过滤条件
if rs.bof and rs.eof then '不存在
'具体代码
end if
rs.filter = "" '恢复记录集
yoki 2003-12-20
  • 打赏
  • 举报
回复
dim strStudentNo as string
dim cn as new adodb.connection
dim rs as new adodb.recordset


cn.open "..........."

strStudentNo='00001'
rs.open "select 1 from student where 学号='"& strStudentNo &"'"
if not rs.eof then msgbox "学号" & strStudentNo &" 已经存在"
leolan 2003-12-20
  • 打赏
  • 举报
回复

rs.open "select * from student where 學號='aaa'"
if not rs.eof then msgbox "已經存在"
wzhjs 2003-12-20
  • 打赏
  • 举报
回复
Set rs=CreateObject("ADODB.Recrodset")

rs.open "SELECT * FROM [students] WHERE [id]=学好",connStr

if not rs.eof then
'存在
else
'不存在
end if
amongwang 2003-12-20
  • 打赏
  • 举报
回复
这其实是很简单的问题!
huluobowangmeng 2003-12-20
  • 打赏
  • 举报
回复
其实都是一样的!~~~~~~~~都是来判断rs.eof是否为True

1,216

社区成员

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

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