选择显示字体大小

用数组实现数据记录的批量录入方法


  <%
rem 文章题目 asp中利用数组实现数据库记录的批量录入方法(原创)
作者:yanek
联系email:aspboy@263.net
%>

包括两个文件
1。allneeddj.asp:实现表单的生成
2. allneeddjresult.asp 处理表单批量录入
3.hbedu.mdb :数据库文件
数据库结构如下
provinceid:省份编号 数值型
dytaocount:打样套数 数值型
papertaocount:纸样套数 数值型
cpcontent:出片内容 数值型
filename:文件名 文本型
beizhu:备注  备注型

本例子中以10条记录,每条记录6个字段说明.

1。allneeddj.asp

<html>

<head>
<meta http-equiv=&quot;content-language&quot; content=&quot;zh-cn&quot;>
<meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=gb2312&quot;>
<meta name=&quot;generator&quot; content=&quot;microsoft frontpage 4.0&quot;>
<meta name=&quot;progid&quot; content=&quot;frontpage.editor.document&quot;>
<title>需求登记</title>
</head>

<body>



<%
set conn=server.createobject(&quot;adodb.connection&quot;)
conn.open &quot;driver={microsoft access driver (*.mdb)};dbq=&quot; & _
             server.mappath(&quot;hbedu.mdb&quot;)

%>

<form method=&quot;post&quot; action=&quot;allneeddjresult.asp&quot;>
  <div align=&quot;center&quot;>
    <center>
  <table border=&quot;1&quot; width=&quot;700&quot; bordercolorlight=&quot;#ffffff&quot;>
    <tr>
      <td width=&quot;660&quot; colspan=&quot;6&quot;>
        <p align=&quot;center&quot;>需求登记</td>
    </tr>
    <tr>
      <td width=&quot;54&quot; align=&quot;center&quot;>省份</td>
      <td width=&quot;66&quot; align=&quot;center&quot;>打样张数</td>
      <td width=&quot;66&quot; align=&quot;center&quot;>纸样张数</td>
      <td width=&quot;66&quot; align=&quot;center&quot;>出片内容</td>
      <td width=&quot;80&quot; align=&quot;center&quot;>文件名</td>
      <td width=&quot;328&quot; align=&quot;center&quot;>
        <p align=&quot;center&quot;>备注</td>
    </tr>
    
    
    <%
rem 通过循环动态生成不同名称表单域
for i=1 to 10
%>
    <%
    set rs=server.createobject(&quot;adodb.recordset&quot;)
sql=&quot;select * from provinceinfo &quot;
rs.open sql,conn,1,1



set rs1=server.createobject(&quot;adodb.recordset&quot;)
sql1=&quot;select * from filename &quot;
rs1.open sql1,conn,1,1
    %>
    
    
    <tr>
      <td width=&quot;54&quot;><select name=&quot;<% response.write&quot;data1&quot;&i %>&quot;
      size=&quot;1&quot;>
<%
              do while not rs.eof
                             if province=cstr(rs(&quot;id&quot;)) then
                                sel=&quot;selected&quot;
                             else
                                sel=&quot;&quot;
                             end if            
                             response.write &quot;<option &quot; & sel & &quot; value='&quot;+cstr(rs(&quot;id&quot;))+&quot;'>&quot;+rs(&quot;province&quot;)+&quot;</option>&quot;+chr(13)+chr(10)
                     rs.movenext
                   loop
                   set rs=nothing
              %>      </select></td>
      <td width=&quot;66&quot;><input type=&quot;text&quot; name=&quot;<% response.write&quot;data2&quot;&i %>&quot; size=&quot;8&quot;></td>
      <td width=&quot;66&quot;><input type=&quot;text&quot; name=&quot;<% response.write&quot;data3&quot;&i %>&quot; size=&quot;8&quot;></td>
      <td width=&quot;66&quot;><select size=&quot;1&quot; name=&quot;<% response.write&quot;data4&quot;&i %>&quot;>
          <option value=&quot;1&quot;>改动部分</option>
          <option value=&quot;2&quot;>全部内容</option>
        </select></td>
      <td width=&quot;80&quot;><select name=&quot;<% response.write&quot;data5&quot;&i %>&quot;
      size=&quot;1&quot;>
<%
              do while not rs1.eof
                             if filename=cstr(rs1(&quot;filename&quot;)) then
                                sel=&quot;selected&quot;
                             else
                                sel=&quot;&quot;
                             end if            
                             response.write &quot;<option &quot; & sel & &quot; value='&quot;+cstr(rs1(&quot;filename&quot;))+&quot;'>&quot;+rs1(&quot;filename&quot;)+&quot;</option>&quot;+chr(13)+chr(10)
                     rs1.movenext
                   loop
                   
                       set rs1=nothing
              %>      </select> </td>
      <td width=&quot;328&quot;><textarea rows=&quot;2&quot; name=&quot;<% response.write&quot;data6&quot;&i %>&quot; cols=&quot;46&quot;></textarea></td>
    </tr>
  
    
    
      <% next %>
    
    
    
    <tr>
      <td width=&quot;660&quot; colspan=&quot;6&quot;>
        <p align=&quot;center&quot;><input type=&quot;submit&quot; value=&quot;提交&quot; name=&quot;b1&quot;></td>
    </tr>
  </table>
    </center>
  </div>
</form>

</body>

</html>

2.allneeddjresult.asp


<%
rem 定义二维数组存放从表单获取的值
dim data(10,6)
for i= 1 to 6
for j= 1 to 10
mydata=&quot;data&quot;+cstr(i)+cstr(j)
data(j,i)=request.form(mydata)
next
next
%>

<%
rem 输出表单输入的值
for i= 1 to 10
for j= 1 to 6

response.write data(i,j)

next
response.write&quot;<br>&quot;
next

'response.end
%>

<%
dim conn,rs
set conn = server.createobject(&quot;adodb.connection&quot;)
conn.open &quot;driver={microsoft access driver (*.mdb)};dbq=&quot; & _
             server.mappath(&quot;hbedu.mdb&quot;)


for i= 1 to 10
rem 循环批量入库

set rs=server.createobject(&quot;adodb.recordset&quot;)
rs.open &quot;hbedu&quot;,conn,1,3
  rs.addnew
  rs(&quot;beizhu&quot;)=data(i,6)
  rs(&quot;filename&quot;)=data(i,5)
  rs(&quot;cpcontent&quot;)=data(i,4)
  rs(&quot;papertaocount&quot;)=data(i,3)
  rs(&quot;dytaocount&quot;)=data(i,2)
  rs(&quot;provinceid&quot;)=data(i,1)
  rs.update
rs.close
set rs=nothing

response.write&quot;ok<br>&quot;
next
%>
演示:http://www.zwtd.com/1/yanek/n/needdj2.asp


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons