问题描述
- 求助:网络中断时 ASP RollbackTrans事务回滚不完全
- 当网络中断 没有完全运行所有代码时 member 表会回滚 但是 shenhe表不回滚
SQL数据库 已经出现了 shenhe表有记录 member没有对应的记录
<%conn.BeginTrans call checkPost() psw=lostsql(trim(request.Form(""psw""))) repsw=lostsql(trim(request.Form(""repsw""))) answer=lostsql(trim(request.Form(""answer""))) reanswer=lostsql(trim(request.Form(""reanswer""))) tjuser=lostsql(trim(request.Form(""tjuser""))) regcode=lostsql(trim(request.Form(""regcode""))) if psw="""" or psw<>repsw then call gotourl(""一级密码不一致!"""back"") end if if answer="""" or answer<>reanswer then call gotourl(""二级密码不一致!"""back"") end if if tjuser="""" then call gotourl(""请填写 直推人帐号!"""back"") end if if tjuser<>"""" then if (conn.execute(""select count(*) from [member] where [lock]=1 and iskt=1 and [user] = '""&tjuser&""'"")(0)<1) then call gotourl(""直推人帐号 填写错误!"""back"") end if end if if regcode="""" then call gotourl(""请填写 注册码!"""back"") end if if regcode<>"""" then if (conn.execute(""select count(*) from [regcode] where [regcode] = '""®code&""'"")(0)<1) then call gotourl(""注册码 填写错误!"""back"") end if end if set rs=server.CreateObject(""adodb.recordset"") rs.open ""select * from member""conn13 rs.addnew rs(""user"")=user rs(""psw"")=md5(psw) rs(""answer"")=md5(answer) rs(""cman"")=lostsql(trim(request.Form(""cman""))) rs(""tel"")=lostsql(trim(request.Form(""tel""))) rs(""qq"")=lostsql(trim(request.Form(""qq""))) rs(""times"")=now() rs(""lock"")=1 rs.update set rsi=server.CreateObject(""adodb.recordset"") rsi.open ""select * from regcode where regcode='""®code&""'""conn13 rsi.delete rsi.update rsi.close set rsi=nothing pp_my=0 if tjuser<>"""" then set rsm=server.CreateObject(""adodb.recordset"") rsm.open ""select * from member where [user]='""&tjuser&""'""conn13 rs(""tjuser"")=tjuser rs(""tjpath"")=rsm(""tjpath"")&rs(""id"")&""/"" rs(""pid"")=rsm(""id"") pp_my=rsm(""pp_my"") rsm.close else rs(""tjuser"")="""" rs(""tjpath"")=""/""&rs(""id"")&""/"" rs(""pid"")=0 end if rs.update fuser=user times=now() rs.close set rs=nothing oldtime=dateadd(""s""-60*60*48now()) paynum=kt_num paytj=0.5 ' 0-找不到匹配转公司 1-直推人 2-时间最早 if pp_my=1 then '------------------------------------------------------------ '时间最早 set rsm=server.CreateObject(""adodb.recordset"") rsm.open ""select top 1 * from member where [lock]=1 and iskt=1 and chajia>0 order by pp_yx desc ktimes asc id asc""conn13 if not rsm.eof then if rsm(""chajia"")-paynum*(1-paytj)>=0 then t_pay=paynum*(1-paytj) else t_pay=rsm(""chajia"") end if paynum=paynum-t_pay rsm(""chajia"")=rsm(""chajia"")-t_pay rsm(""pnum"")=rsm(""pnum"")+1 rsm.update set rsi=server.CreateObject(""adodb.recordset"") rsi.open ""select * from shenhe""conn13 rsi.addnew rsi(""fuser"")=fuser rsi(""num"")=t_pay rsi(""lid"")=0 rsi(""tuser"")=rsm(""user"") rsi(""times"")=times rsi(""tid"")=2 '时间最早 rsi.update rsi.close set rsi=nothing else '没有匹配时 匹配到公司帐号 set rsg=server.CreateObject(""adodb.recordset"") rsg.open ""select * from member where [user]='""&gs_user&""'""conn13 rsg(""chajia"")=rsg(""chajia"")-paynum*(1-paytj) rsg(""pnum"")=rsg(""pnum"")+1 paynum=paynum*paytj rsg.update set rsi=server.CreateObject(""adodb.recordset"") rsi.open ""select * from shenhe""conn13 rsi.addnew rsi(""fuser"")=fuser rsi(""num"")=paynum*(1-paytj) rsi(""lid"")=0 rsi(""tuser"")=gs_user rsi(""times"")=times rsi(""tid"")=0 '找不到匹配转公司 rsi.update rsi.close set rsi=nothing rsg.close set rsg=nothing end if rsm.close set rsm=nothing '直推人 set rsg=server.CreateObject(""adodb.recordset"") rsg.open ""select * from member where [user]='""&tjuser&""'""conn13 rsg(""chajia"")=rsg(""chajia"")-paynum rsg(""pnum"")=rsg(""pnum"")+1 rsg.update set rsi=server.CreateObject(""adodb.recordset"") rsi.open ""select * from shenhe""conn13 rsi.addnew rsi(""fuser"")=fuser rsi(""num"")=paynum rsi(""lid"")=0 rsi(""tuser"")=tjuser rsi(""times"")=times rsi(""tid"")=1 '直推人 rsi.update rsi.close set rsi=nothing rsg.close set rsg=nothing '------------------------------------------------------------ else '------------------------------------------------------------ '时间最早 set rsm=server.CreateObject(""adodb.recordset"") rsm.open ""select top 2 * from member where [lock]=1 and iskt=1 and chajia>0 order by pp_yx desc ktimes asc id asc""conn13 if not rsm.eof then rsm.movefirst '第一个 if rsm(""chajia"")-paynum>=0 then t_pay=paynum else t_pay=rsm(""chajia"") end if paynum=paynum-t_pay rsm(""chajia"")=rsm(""chajia"")-t_pay rsm(""pnum"")=rsm(""pnum"")+1 rsm.update set rsi=server.CreateObject(""adodb.recordset"") rsi.open ""select * from shenhe""conn13 rsi.addnew rsi(""fuser"")=fuser rsi(""num"")=t_pay rsi(""lid"")=0 rsi(""tuser"")=rsm(""user"") rsi(""times"")=times rsi(""tid"")=2 '时间最早 rsi.update rsi.close set rsi=nothing '匹配完第一个有剩余 if paynum>0 then if rsm.recordcount=2 then rsm.movenext '第二个 if rsm(""chajia"")-paynum>=0 then rsm(""chajia"")=rsm(""chajia"")-paynum rsm(""pnum"")=rsm(""pnum"")+1 rsm.update set rsi=server.CreateObject(""adodb.recordset"") rsi.open ""select * from shenhe""conn13 rsi.addnew rsi(""fuser"")=fuser rsi(""num"")=paynum rsi(""lid"")=0 rsi(""tuser"")=rsm(""user"") rsi(""times"")=times rsi(""tid"")=2 '时间最早 rsi.update rsi.close set rsi=nothing else '有剩余 匹配到公司帐号 set rsg=server.CreateObject(""adodb.recordset"") rsg.open ""select * from member where [user]='""&gs_user&""'""conn13 rsg(""chajia"")=rsg(""chajia"")-paynum rsg(""pnum"")=rsg(""pnum"")+1 rsg.update set rsi=server.CreateObject(""adodb.recordset"") rsi.open ""select * from shenhe""conn13 rsi.addnew rsi(""fuser"")=fuser rsi(""num"")=paynum rsi(""lid"")=0 rsi(""tuser"")=gs_user rsi(""times"")=times rsi(""tid"")=0 '找不到匹配转公司 rsi.update rsi.close set rsi=nothing rsg.close set rsg=nothing end if else '没有第二个匹配 且有剩余 匹配到公司帐号 set rsg=server.CreateObject(""adodb.recordset"") rsg.open ""select * from member where [user]='""&gs_user&""'""conn13 rsg(""chajia"")=rsg(""chajia"")-paynum rsg(""pnum"")=rsg(""pnum"")+1 rsg.update set rsi=server.CreateObject(""adodb.recordset"") rsi.open ""select * from shenhe""conn13 rsi.addnew rsi(""fuser"")=fuser rsi(""num"")=paynum rsi(""lid"")=0 rsi(""tuser"")=gs_user rsi(""times"")=times rsi(""tid"")=0 '找不到匹配转公司 rsi.update rsi.close set rsi=nothing rsg.close set rsg=nothing end if end if else '没有匹配时 匹配到公司帐号 set rsg=server.CreateObject(""adodb.recordset"") rsg.open ""select * from member where [user]='""&gs_user&""'""conn13 rsg(""chajia"")=rsg(""chajia"")-paynum rsg(""pnum"")=rsg(""pnum"")+1 rsg.update set rsi=server.CreateObject(""adodb.recordset"") rsi.open ""select * from shenhe""conn13 rsi.addnew rsi(""fuser"")=fuser rsi(""num"")=paynum rsi(""lid"")=0 rsi(""tuser"")=gs_user rsi(""times"")=times rsi(""tid"")=0 '找不到匹配转公司 rsi.update rsi.close set rsi=nothing rsg.close set rsg=nothing end if rsm.close set rsm=nothing '------------------------------------------------------------ end ifif conn.errors.count=0 then conn.CommitTrans call gotourl(""注册成功!""mymember.asp""")else conn.RollbackTrans call gotourl(""失敗nn""&err.description"back"")end if%>
解决方案
我用手机看,不方便,但这种情况,我想到一种情况,你看看是不是外键的原因
时间: 2024-11-02 17:01:27