没有该记录才插入怎么实现

curious 2000-05-27 08:26:00
我用recordcount判断,结果仍然插入了

set rs=server.createobject("adodb.recordset")
sql="select * from table1 where aaa= 's' "
rs.open sql,conn,3,3
if rs.recordcount=0 then
rs.addnew
rs("aaa")=s
rs.update
end if
rs.close
...全文
132 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
july 2000-05-27
  • 打赏
  • 举报
回复
if not exists(select * from table where) then
insert into table
else
update table
end if
zdg 2000-05-27
  • 打赏
  • 举报
回复
试一试
sql="select * from table1 where aaa= 's' "
set rs=Conn.Execute(sql)
if rs.EOF then
......
end if
rs.close
Again 2000-05-27
  • 打赏
  • 举报
回复
给你的TABLE设唯一关键字段,如果继续Insert,ODBC应该会报错
然后用zdg的方法试一试

28,390

社区成员

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

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