想查一下ID是否存在,应该如何实现?

adron 2001-07-13 01:22:11
flag="1"
<%
sql="select id from renlit"
rs.open sql,cn,1,1
do while not rs.eof
if id=rs("id")and flag="1" then
%>
<center>
您的输入出现相同的编号,该操作非法!<p>
<a href="../renli/renin.asp">返回</a>
</center>
<%
flag="0"
end if
rs.movenext
loop
%>
大侠,帮小弟看看,?

...全文
161 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
gooyan 2001-07-13
  • 打赏
  • 举报
回复
同意liugys(liuliu)的看法
liugys 2001-07-13
  • 打赏
  • 举报
回复
是判断rs记录是否到了头指针(bof)或尾指针(eof),也就是判断记录集是否为空
adron 2001-07-13
  • 打赏
  • 举报
回复
妙!
not (rs.bof and rs.eof)
这个条件用来判定指针已指向了某个记录。是这样的把?!
adron 2001-07-13
  • 打赏
  • 举报
回复
to truemichael:
非常感谢,用你的试了以后,问题解决了!谢谢!
to Muf:
虽然你的解答还是有问题,但我看你和truemichael的意思差不多。
我有个疑问,就是为何我的那段里if id=rs("id")判断不出id=rs("id")
liugys 2001-07-13
  • 打赏
  • 举报
回复
同意Muf(沐枫) 的!
<%
sql="select id from renlit wher id='"&id&"'"
rs.open sql,cn,1,1
if not rs.eof then
response.write "您的输入出现相同的编号,该操作非法!<p>"&_
"<a href='../renli/renin.asp'>返回</a>"
response.clear
response.end
else
%>
这里是正常显示的内容
<%
end if
%>
jdxx 2001-07-13
  • 打赏
  • 举报
回复
对啊,用自动编号不好吗?
netjiang 2001-07-13
  • 打赏
  • 举报
回复
用自动编号不好吗?
netjiang 2001-07-13
  • 打赏
  • 举报
回复
我会用truemichael(truemichael)的方法写。
adron 2001-07-13
  • 打赏
  • 举报
回复
是这样的:我建了张表,ID是其中的一个字段int型。用来放编号的。
它不允许有重复的值,(不是主键)
现在我要提交一个表单,需要验证一下是否有重复的ID,有则返回。
Muf 2001-07-13
  • 打赏
  • 举报
回复
<%
sql="select id from renlit wher id='"&id&"'"
rs.open sql,cn,1,1
if rs.eof then
%>
<center>
您的输入出现相同的编号,该操作非法!<p>
<a href="../renli/renin.asp">返回</a>
</center>
<%
end if
%>
truemichael 2001-07-13
  • 打赏
  • 举报
回复
rs.open sql,cn,1,1
if not (rs.bof and rs.eof) then
....存在
else
...不存在
end if
jdxx 2001-07-13
  • 打赏
  • 举报
回复
不知道你说的什么意思

28,390

社区成员

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

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