当前位置: 首页 > 图文教程 > 网络编程 > ASP > asp中利用数组实现数据库记录的批量录入方法

ASP
ASP技巧:在Access数据库中重命名表
用ASP编程实现网络内容快速查找
比较ASP生成静态HTML文件的几种方法
ASP实例:实现邮件发送普通附件和嵌入附件
如何用ASP实现去掉三个最高分和三个最低分
ASP实例:Access为后台数据库的网站统计系统
用标签替换的方法生成静态网页
例程:用ASP判断文件地址是否有效
学ASp动态网页必备:常用的38个函数
ASP教程:初次接触学习ASP脚本程序
ASPJPEG水印中关于文字水印的帮助文档(中英文对照)
ASP例子:ASP把汉字转化为拼音的函数
ASP教程:学习ASP应用Cookies的技巧
ASP入门:认识ASP程序所使用的几种脚本语言
初学者的ASP教程:常用ASP内置函数
ASP初级教程之ASP对表单和用户输入的处理
学习ASP文件引用的方法
用ASP编写更人性化的弹出窗口程序
谈谈学习ASP动态网页制作技术的编程心得
用ASP程序实现网站在线人数统计

ASP 中的 asp中利用数组实现数据库记录的批量录入方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 35 ::
收藏到网摘: n/a

asp中利用数组实现数据库记录的批量录入方法(原创)
演示:http://www.zwtd.com/1/yanek/n/needdj2.asp
<%
rem 文章题目 asp中利用数组实现数据库记录的批量录入方法(原创)
作者:yanek
联系email:[email protected]
%>

包括两个文件
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="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>需求登记</title>
</head>

<body>

<%
set conn=server.createobject("adodb.connection")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & _
Server.MapPath("hbedu.mdb")

%>

<form method="POST" action="allneeddjresult.asp">
<div align="center">
<center>
<table border="1" width="700" bordercolorlight="#FFFFFF">
<tr>
<td width="660" colspan="6">
<p align="center">需求登记</td>
</tr>
<tr>
<td width="54" align="center">省份</td>
<td width="66" align="center">打样张数</td>
<td width="66" align="center">纸样张数</td>
<td width="66" align="center">出片内容</td>
<td width="80" align="center">文件名</td>
<td width="328" align="center">
<p align="center">备注</td>
</tr>


<%
rem 通过循环动态生成不同名称表单域
for i=1 to 10
%>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from provinceinfo "
rs.open sql,conn,1,1

set rs1=server.createobject("adodb.recordset")
sql1="select * from filename "
rs1.open sql1,conn,1,1
%>


<tr>
<td width="54"><select name="<% response.write"data1"&i %>"
size="1">
<%
do while not rs.eof
if province=cstr(rs("id")) then
sel="selected"
else
sel=""
end if
response.write "<option " & sel & " value='"+CStr(rs("id"))+"'>"+rs("province")+"</option>"+chr(13)+chr(10)
rs.movenext
loop
set rs=nothing
%> </select></td>
<td width="66"><input type="text" name="<% response.write"data2"&i %>" size="8"></td>
<td width="66"><input type="text" name="<% response.write"data3"&i %>" size="8"></td>
<td width="66"><select size="1" name="<% response.write"data4"&i %>">
<option value="1">改动部分</option>
<option value="2">全部内容</option>
</select></td>
<td width="80"><select name="<% response.write"data5"&i %>"
size="1">
<%
do while not rs1.eof
if filename=cstr(rs1("filename")) then
sel="selected"
else
sel=""
end if
response.write "<option " & sel & " value='"+CStr(rs1("filename"))+"'>"+rs1("filename")+"</option>"+chr(13)+chr(10)
rs1.movenext
loop

set rs1=nothing
%> </select> </td>
<td width="328"><textarea rows="2" name="<% response.write"data6"&i %>" cols="46"></textarea></td>
</tr>



<% next %>



<tr>
<td width="660" colspan="6">
<p align="center"><input type="submit" value="提交" name="B1"></td>
</tr>
</table>
</center>
</div>
</form>

</body>

</html>

2.allneeddjresult.asp


<%
rem 定义二维数组存放从表单获取的值