日期:2014-05-17  浏览次数:20943 次

为什么我保存一次,表里出现两条一模一样的记录!(在线等!)
<!--#include   file= "../conn/dbconn1.asp "-->
<!--#include   file= "../inc/classcount.asp "-->
<!--#include   file= "../inc/safe.asp "-->
<%
VerifyCode   =   Replace(Trim(Request( "VerifyCode ")), " ' ", " ")
if     VerifyCode   <>   CStr(Session( "GetCode "))     then  
response.write   " <SCRIPT   language=JavaScript> alert( '验证码有误,请重新输入! '); "
      response.write "this.location.href= 'javascript:history.back(); ' </SCRIPT> "
Response.End
else
userid=Replace(Trim(request.form( "ordername3 ")), " ' ", " ")
OrderNum=Replace(Trim(request.form( "Ordername ")), " ' ", " ")
Comane=   Replace(Trim(request.form( "Comane ")), " ' ", " ")
RecName=   Replace(Trim(request.form( "RecName ")), " ' ", " ")
RecAddress=   Replace(Trim(request.form( "RecAddress ")), " ' ", " ")
ZipCode=   Replace(Trim(request.form( "ZipCode ")), " ' ", " ")
RecPhone=   Replace(Trim(request.form( "RecPhone ")), " ' ", " ")
Fox=   Replace(Trim(request.form( "Fox ")), " ' ", " ")
RecMail=   Replace(Trim(request.form( "RecMail ")), " ' ", " ")
Notes=   Replace(Trim(request.form( "Notes ")), " ' ", " ")
PayType=   Replace(Trim(request.form( "PayType2 ")), " ' ", " ")
set   rs=server.CreateObject( "adodb.recordset ")
sql= "select   *   from   orderlist "
rs.open   sql,conn,1,3
rs.addnew
rs( "userid ")=userid
rs( "ordernum ")=ordernum
rs( "comane ")=comane
rs( "recname ")=recname
rs( "recaddress ")=recaddress
rs( "zipcode ")=zipcode
rs( "recphone ")=recphone
rs( "fox ")=fox
rs( "recmail ")=recmail
rs( "notes ")=notes
rs( "paytype ")=paytype
rs.update
rs.close
conn.close
response.write   "订单提交成功 "
end   if

%>

------解决方案--------------------
代码正确啊!没有看到什么毛病,不知了.


用insert试试,

sql= "insert into ... "
这样速度快.用conn.execute(sql)
------解决方案--------------------
这个子问题上次有人问过了,应该是在表单认证那里重复提交了
------解决方案--------------------
response.write " <SCRIPT language=JavaScript> alert( '验证码有误,请重新输入! '); "
response.write "this.location.href= 'javascript:history.back(); ' </SCRIPT> "
Response.End

不用后退,直接转到页面去,后退的话,后面的代码还是会执行,这样就有2条一样的记录了