当前位置:Gxlcms > ASP > 批量复制数据

批量复制数据

时间:2021-07-01 10:21:17 帮助过:95人阅读

现有表Special和表view数据结构相同的两个表:
代码如下:
Special
Specialid       NClass        name           pic
1                   黎明          火舞艳阳
2                   张学友      地久天长
3                   陈冠希      同名专辑
4                   郭富城      听风的歌
view
Specialid       NClass        name           pic
1                   黎明          火舞艳阳      photo/200606192321.jpg
2                   张学友      地久天长      photo/200606192327.jpg
3                   刘德华      如果有一天 photo/200606192328.jpg
4                   郭富城      听风的歌      photo/200606192329.jpg

要将VIEW中的PIC数据批量复制到Special中,(歌手名与专辑要完全相同),代码如下:
  1. <br><span><u></u></span> 代码如下:<%  <br>   dim conn     <br>   dim connstr  <br>   'on error resume next  <br>   connstr="DBQ="+server.mappath("p#1.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"  <br>   set conn=server.createobject("ADODB.CONNECTION")  <br>On Error Resume Next  <br>   conn.open connstr   <br>%>  <br><html>  <br><head>  <br><title>管理软件</title>  <br><meta http-equiv="Content-Type" content="text/html; charset=gb2312">  <br></head>  <br><body bgcolor="#FFFFFF" text="#000000"  >  <br><table width=700 border="0" cellspacing="0" cellpadding="0"  align="center"><%  <br>   const MaxPerPage=100  <br>   dim totalPut     <br>   dim CurrentPage  <br>   dim TotalPages  <br>   dim i,j  <br>   if not isempty(request("page")) then  <br>      currentPage=cint(request("page"))  <br>   else  <br>      currentPage=1  <br>   end if  <br>%>  <br><%  <br>set rs=server.CreateObject("adodb.recordset")  <br>rs.open "select  *  from Special inner join view on Special.name =view.name and Special.NClass=view.NClass",conn,1,1  <br>  if rs.eof and rs.bof then  <br>       response.write "<p align=center class=font>暂无软件</p>"  <br>   else  <br>   totalPut=rs.recordcount  <br>      totalPut=rs.recordcount  <br>      if currentpage<1 then  <br>          currentpage=1  <br>      end if  <br>      if (currentpage-1)*MaxPerPage>totalput then  <br>    if (totalPut mod MaxPerPage)=0 then  <br>      currentpage= totalPut MaxPerPage  <br>    else  <br>       currentpage= totalPut MaxPerPage + 1  <br>    end if  <br>      end if  <br>       if currentPage=1 then  <br>            showContent  <br>            showpage totalput,MaxPerPage,"l.asp"  <br>       else  <br>          if (currentPage-1)*MaxPerPage<totalPut then  <br>            rs.move  (currentPage-1)*MaxPerPage  <br>            dim bookmark  <br>            bookmark=rs.bookmark  <br>            showContent  <br>             showpage totalput,MaxPerPage,"l.asp"  <br>        else  <br>         currentPage=1  <br>           showContent  <br>           showpage totalput,MaxPerPage,"l.asp"  <br>       end if  <br>    end if  <br>   rs.close  <br>   end if  <br><br>   set rs=nothing    <br>   conn.close  <br>   set conn=nothing  <br>   sub showContent  <br>       dim i  <br>    i=1  <br>%>  <br>      <%do while not rs.eof%>  <br><tr>   <br><td><%dim picc,vname,vnclass  <br>picc=rs("pic")  <br>vname=rs("name")  <br>vnclass=rs("nclass")%><%  <br>sql="update Special set pic='"&picc&"' where name='"&vname&"'  and nclass='"&vnclass&"'  "  <br>conn.execute sql  <br>%></td>  <br></tr>  <br><% i=i+1  <br>if i>=MaxPerPage then exit do  <br>rs.movenext  <br>loop  <br>%>  <br></table>  <br>      <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">  <br>        <tr>   <br>          <td height="21" bgcolor="#F7F7F7" align="center">  <br><%  <br>end sub   <br>function showpage(totalnumber,maxperpage,filename)  <br>  dim n  <br>  if totalnumber mod maxperpage=0 then  <br>     n= totalnumber maxperpage  <br>  else  <br>     n= totalnumber maxperpage+1  <br>  end if  <br>  if CurrentPage<2 then  <br>    response.write ""  <br>  else  <br>    response.write "<a href="&filename&"?page=1>首页</a> "  <br>    response.write "<a href="&filename&"?page="&CurrentPage-1&">上一页</a> "  <br>  end if  <br>  if n-currentpage<1 then  <br>    response.write ""  <br>  else  <br>    response.write "<a href="&filename&"?page="&(CurrentPage+1)&">"  <br>    response.write "下一页</a> <a href="&filename&"?page="&n&">尾页</a>"  <br>  end if  <br>   response.write " 页次:</font><b><font color=red>"&CurrentPage&"</font>/"&n&"</b>页</font> "  <br>    response.write " 共<b>"&totalnumber-1&"</b>个软件 <b>"&maxperpage&"</b>个软件/页"  <br>end function  <br>%>  <br>    </td>  <br>  </tr>  <br></table>  <br></body>  <br></html> 

人气教程排行