当前位置:编程学习 > C#/ASP.NET >>

请高手指点 asp查询后保存问题

其实就是和网上订货系统一样,我在购物车界面aa中可能有多条数据,这多条数据是在数据库表sp中,现在我点击保存按钮想把部分信息保存在数据库spdd中,例如:从订单数据库表sp中的je保存在数据库表spdd,含税金额中!怎么实现? 
购物页面: <TD height=50 colspan="3"> <form name="form1"  method="post"  action="savedd.asp"> 
<table class=table cellspacing=1 cellpadding=4 width="100%" align=center border=0> 
                  <tbody> 
                    <tr align=middle> 
                      <td class=title width=35 height=22>编号 </td> 
                      <td class=title width=165 height=19>商品名称 </td> 
                      <td class=title width=87 height=19>商品产地 </td> 
                      <td class=title width=57 height=19>商品规格 </td> 
                      <td class=title width=33 height=19>单位 </td> 
                      <td class=title width=42 height=19>剂型 </td> 
                      <td class=title width=61 height=19>剂量规格 </td> 
                      <td class=title width=57 height=19>价格(元) </td> 
                      <td class=title width=35 height=19>数量 </td> 
                      <td class=title width=38 height=19>金额 </td> 
                      <td class=title width=38 height=19>删除 </td> 
                    </tr> 
                    <% 
sum=0 
k=0 
array1=split(Session("spid"),":") 
array2=split(Session("num"),":") 


do while k < ubound(array1) 

  dim conn  
  dim connstr 

  on error resume next 
  connstr="DBQ="+server.mappath("khdatasecret/global.asa")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};" 
  

  set conn=server.createobject("ADODB.CONNECTION") 
  if err then 
      err.clear 
  else 
        conn.open connstr,3,3 
        if err then 
          err.clear 
        end if 
  end if 
Set rs = Server.CreateObject("ADODB.Recordset") 
spbh=replace(array1(k),"'","") 
sql = "SELECT * FROM sp where spid='"& spbh &"'" 

rs.open sql,conn,1,1 

%> 
                    <tr class=title align=middle> 
                      <td class=title> <%=k+1%> </td> 
                      <td class=title> <%=rs("spmch")%> </td> 
                      <td class=title> <%=rs("shpchd")%> </td> 
                      <td class=title> <%=rs("shpgg")%> </td> 
                      <td class=title> <%=rs("dw")%> </td> 
                      <td class=title> <%=rs("jixing")%> </td> 
                      <td class=title> <%=rs("jlgg")%> </td> 
                      <td class=title> <input name="sjj" type="text"  id="sjj" value=" <%=rs("hshsj")%>" size="6" format="format"> </td> 
                      <td class=title> <%=array2(k)%> </td> 
                      <td class=title> <%=array2(k)*rs("lshj")%> </td> 
                      <td width="38" class=title> <a href="delsp.asp?id= <%=K%>">删除 </a> </td> 
                    </tr> 
                    <% 
sum=sum+rs("lshj")*array2(k) 
rs.close 
set rs=nothing  
k=k+1 
loop %> 
                    <tr> 
                      <td align="center" height="42" class="title" colspan="2"> 
                        <input type="submit" name="Submit" value="提交订单"> 
                      </td> 
                      <td align="center" height="42" class="title" colspan="3"> <a href="shop.asp">*继续购物* </a> </td> 
                      <td align="center" class="title"> <b>金额: </b> </td> 
                      <td align="center" class="title" colspan="3"> <b> <%=sum%>元 </b> </td> 
                      <td align="center" class="title">  </td> <td align="center" class="title">  </td> 
                    </tr> 
                  </tbody> 
                </table> </form> </TD> 

数据库部门: <% 

if Len(Session("login"))=0 then 
Response.Write(" <script language=""JavaScript"">"&_ 
"parent.location=""default.asp"";"&_ 
" </script>") 
end if 


m=0 
k=0 

array1=split(Session("spid"),":") 
array2=split(Session("num"),":") 


  dim conn  
  dim connstr 

  on error resume next 
  connstr="DBQ="+server.mappath("khdatasecret/global.asa")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};" 
  

  set conn=server.createobject("ADODB.CONNECTION") 
  if err then 
      err.clear 
  else 
        conn.open connstr,3,3 
        if err then 
          err.clear 
        end if 
  end if 
Set rs = Server.CreateObject("ADODB.Recordset") 
spbh=replace(array1(k),"'","") 
sql = "SELECT * ,(select * from sp where spid='"&array1(m)&"')as hsje FROM spdd  " 

rs.open sql,conn,1,3 
dim ranNum,Summer  
randomize 
ranNum = int(90000*rnd)+10000 
Summer=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum 
m=Summer 
do while k < ubound(array1) 
dim str 
str="update spdd set djsn='"&k&"',spid='"&array1(k)&"' where  id="&array1(k)'更新数据库 
rs.addnew 
rs("djsn")=k 
rs("spid")=array1(k) 
rs("shl")=array2(k) 
rs("hsje")=request.Form("sjj") 
rs("user")=Session("login") 
rs("dwmch")=Session("dwmch") 
rs("rq")=now() 
rs("rq1")=date() 

rs("djbh")=m 

rs.update 

k=k+1 
loop 

do while m < ubound(array1) 

Set rs1=Server.CreateObject("ADODB.Recordset") 

sql1="select * from sp where spid='"&array1(m)&"'" 
rs1.open sql1,conn,1,3 
data1=rs1("kcshl") 

rs1("kcshl")=data1-array2(m) 
rs1.update 
rs1.close 
set rs1=nothing 
m=m+1 
loop 


Response.Write " <script language=JavaScript>{window.alert('订单保存成功,谢谢合作!');window.location.href('shop.asp');} </script>" 
rs.close 
set rs=nothing 
Session("spid")="" 
Session("num")="" 

%> --------------------编程问答-------------------- sorry,不会asp,帮顶 --------------------编程问答-------------------- 读了2遍要求还有点没明白,
--------------------编程问答-------------------- 楼主你想做什么呀?不会把网站全贴出来了吧,
你少弄点儿,才会有人敢看贴呀!
看了半天,没看明白。要不您再组织一下语言??? --------------------编程问答-------------------- 谢谢各位仁兄!我发代码主要是想把问题说明白点!明天我把问题简单说一下 --------------------编程问答-------------------- 你想解决问题心切,我理解你
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,