asp插入数据的时候怎么会同时插入了两条记录呢

来源:百度知道 编辑:UC知道 时间:2024/05/22 12:42:05
add_mana1.asp
<!--#include file="conn.asp"-->
<%
dim usm,pa
usm=request.Form("us")
pa=request.Form("pass")
per=request.Form("select")

'获得数据集

sql = "select username from users"
RsName rs,sql,1,1

do while not rs.eof
if usm = rs("username") then

response.write("<script>alert('此帐号已存在');window.history.go(-1)</script>")
response.End()
end if
rs.movenext
loop
CloseRs()

if usm="" or pa="" then
response.write("<script>alert('帐号或密码不能为空!');window.history.go(-1)</script>")
response.End()

end if

'获得数据集
sql = "insert into users(username,p_word,p

可能是因为你同时打开了两个页面造成的插入两打记录.
因为同时打开,且是在客户端执行判断语句.所以,两个页面所得到的值是一样的,都是没有记录,然后同时执行插入命令。
把判断语句的处理方式改用Application对像来处理,同时用lock与unlock来处理.

RsName rs,sql,1,1

conn.Execute(sql)

这2个你随便去掉一个.