ASP判断是否已存在问题!急!

凡夫与俗子 2009-06-08 09:35:22
下面是修改的一段代码,我想加一个判断,就是修改后的产品信息假如与已存在的产品重名(p_name),则给出提示,这个判断语句加在什么地方,代码是什么?

if action="edit" then 'start update record
'开始修改更新产品
if p_name="" or p_bcid="0" or p_scid="0" or p_bid="0" then
response.Write "<script>alert('带*号为必填项,请填写完整!')</script>"
response.End()
else
dim sqlup
set rs=server.CreateObject("adodb.recordset")
sqlup= "select * from products where p_id=" & p_id
rs.open sqlup,conn,1,3
if not rs.bof or not rs.eof then
Rs("p_name") = p_name
Rs("p_bcid") = p_bcid
Rs("p_scid") = p_scid
Rs("p_bid") = p_bid
Rs("p_type") = p_type
Rs("p_sn") = p_sn
Rs("p_sdw") = p_sdw
Rs("p_bdw") = p_bdw
Rs("p_hs") = p_hs
Rs("p_info") = p_info
Rs("p_pyjm") = p_pyjm
Rs("p_uid") = p_uid
Rs("p_addtime") = p_addtime
rs.update
rs.close
set rs=nothing
response.Write("<script>alert('修改成功!')</script>")
response.End()
end if
end if
end if
...全文
95 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
凡夫与俗子 2009-06-08
  • 打赏
  • 举报
回复
3q
ziyuanxian 2009-06-08
  • 打赏
  • 举报
回复
先查数据库里的内容(即查找数据库里有没有相同内容,如果有相同的,就返回提示),再做比较
set rs=server.CreateObject("adodb.recordset")
sqlup= "select * from products where p_name=" & p_name
rs.open sqlup,conn,1,3
if not rs.bof or not rs.eof then
'提示错误
else
.....
end if

28,391

社区成员

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

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