猿问

请问想做一个报表的添加功能,在添加的时候需要查询报表的编号是否重复?如何实现?

我想做一个报表的添加功能,在添加的时候需要查询报表的编号是否重复,如果重复就不执行添加,弹出提示窗口,我的程序如下:
dim biaohao1
biaohao1=trim(request("biaohao"))//biaohao是文本框的name
set rs=server.createobject("adodb.recordset")
sql="select * from yuanliao_in_store"
rs.open sql,conn,1,3
我想在这个地方添加一个FOR语句,可是就是不成功,语句如下
for i=1 to rs.recordcount
if rs.eof then exit for
if(biaohao1=(response.write(rs("biaohao")))
{
alert("编号重复!");
return (false);
}
next
rs.close
希望高手速度解围,小弟谢谢了!急。
rs.addnew
rs("chushengdi") = trim(request.Form("chushengdi"))
rs("jiesheng") = trim(request.Form("jiesheng"))
rs("bianhao") = trim(request.Form("bianhao1"))
rs("jigou") = trim(request.Form("jigou"))
rs("uptime") = request.Form("uptime")
rs("jingbanren") = jingbanren
rs("jieshengyuan") = trim(request.Form("jieshengyuan"))

rs("content") = trim(request.Form("content"))
rs.update
response.Write "<script language=javascript>alert('录入成功!');</script>"
response.write "<meta http-equiv=""refresh"" content=""0;url=yuanliao_in_store.asp"">"
response.end
rs.close
set rs=nothing
end sub

红糖糍粑
浏览 159回答 1
1回答

跃然一笑

sql="select * from yuanliao_in_store"rs.open sql,conn,1,3我想在这个地方添加一个FOR语句,可是就是不成功,语句如下for i=1 to rs.recordcountif rs.eof then exit forif(biaohao1=(response.write(rs("biaohao"))){alert("编号重复!");return (false);}next这里改成这样 :sql="select * from yuanliao_in_store where biaohao="&biaohao1rs.open sql,conn,1,3if not rs.eof thenrs.closeresponse.Write "<script language=javascript>alert('编号重复');</script>"elsers.addnewrs("chushengdi") = trim(request.Form("chushengdi"))rs("jiesheng") = trim(request.Form("jiesheng"))rs("bianhao") = trim(request.Form("bianhao1"))rs("jigou") = trim(request.Form("jigou"))rs("uptime") = request.Form("uptime")rs("jingbanren") = jingbanrenrs("jieshengyuan") = trim(request.Form("jieshengyuan"))rs("content") = trim(request.Form("content"))rs.updateresponse.Write "<script language=javascript>alert('录入成功!');</script>"rs.closeset rs=nothingresponse.endresponse.write "<meta http-equiv=""refresh"" content=""0;url=yuanliao_in_store.asp"">"end ifend sub
随时随地看视频慕课网APP
我要回答