| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3619 人关注过本帖
标题:[求助]asp批量添加access数据该怎么写
只看楼主 加入收藏
ykxiaoqi
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-8-8
收藏
 问题点数:0 回复次数:4 
[求助]asp批量添加access数据该怎么写
求助asp批量添加access数据该怎么写
搜索更多相关主题的帖子: access数据 asp批量 
2007-09-26 10:37
hmhz
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:30
帖 子:1890
专家分:503
注 册:2006-12-17
收藏
得分:0 

用循环:

for i=1 to 5 '可以自定义添加数量
conn.execute "insert into words(word,times) values('"&request.form("word"&i)&"','"&now()&"')"
next


[编程论坛] ASP超级群:49158383  敲门暗号:ASP编程
龍艺博客 http://www.
2007-09-26 12:09
天涯听雨
Rank: 2
来 自:东莞
等 级:论坛游民
威 望:4
帖 子:497
专家分:64
注 册:2007-8-25
收藏
得分:0 
没有什么批量的方法,批量时只是循环执行……

从明天起做幸福的人,喂马劈柴周游世界!
2007-09-26 15:09
madpbpl
Rank: 4
等 级:贵宾
威 望:11
帖 子:2876
专家分:244
注 册:2007-4-5
收藏
得分:0 
给你个具体操作的例子,结合楼上两个朋友的方法就可以批量操作了。
[url]http://hi.baidu.com/myxxl/blog/item/3edcbd4b58931cf083025c44.html[/url]
2007-09-26 15:36
guaishi
Rank: 1
等 级:新手上路
帖 子:156
专家分:0
注 册:2007-6-15
收藏
得分:0 

表单部分

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>批量输入信息</title>
</head>
<body>
<form action="addallda.asp" method="post" name="form" target="_self">
<table width="1036" border="1">
<tr>
<td width="168">姓名</td>
<td width="60">性别</td>
<td width="168">电话</td>
<td width="180">地址</td>
<td width="251">业务员</td>
<td width="169">备注</td>
</tr>
<tr>
<td><input name="xm1" type="text" id="xm1"></td>
<td><select name="xb1" id="xb1">
<option>男</option>
<option>女</option>
</select></td>
<td><input name="tel1" type="text" id="tel1"></td>
<td><input name="address1" type="text" id="address1"></td>
<td><input name="yewu1" type="text" id="yewu1"></td>
<td><input name="beizhu1" type="text" id="beizhu1"></td>
</tr>
<tr>
<td><input name="xm2" type="text" id="xm2"></td>
<td><select name="xb2" id="xb2">
<option>男</option>
<option>女</option>
</select></td>
<td><input name="tel2" type="text" id="tel2"></td>
<td><input name="address2" type="text" id="address2"></td>
<td><input name="yewu2" type="text" id="yewu2"></td>
<td><input name="beizhu2" type="text" id="beizhu2"></td>
</tr>
<tr>
<td><input name="xm3" type="text" id="xm3"></td>
<td><select name="xb3" id="xb3">
<option>男</option>
<option>女</option>
</select></td>
<td><input name="tel3" type="text" id="tel3"></td>
<td><input name="address3" type="text" id="address3"></td>
<td><input name="yewu3" type="text" id="yewu3"></td>
<td><input name="beizhu3" type="text" id="beizhu3"></td>
</tr>
<tr>
<td><input name="xm4" type="text" id="xm4"></td>
<td><select name="xb4" id="xb4">
<option>男</option>
<option>女</option>
</select></td>
<td><input name="tel4" type="text" id="tel4"></td>
<td><input name="address4" type="text" id="address4"></td>
<td><input name="yewu4" type="text" id="yewu4"></td>
<td><input name="beizhu4" type="text" id="beizhu4"></td>
</tr>
<tr>
<td><input name="xm5" type="text" id="xm5"></td>
<td><select name="xb5" id="xb5">
<option>男</option>
<option>女</option>
</select></td>
<td><input name="tel5" type="text" id="tel5"></td>
<td><input name="address5" type="text" id="address5"></td>
<td><input name="yewu5" type="text" id="yewu5"></td>
<td><input name="beizhu5" type="text" id="beizhu5"></td>
</tr>
<tr>
<td><input name="xm6" type="text" id="xm6"></td>
<td><select name="xb6" id="xb6">
<option>男</option>
<option>女</option>
</select></td>
<td><input name="tel6" type="text" id="tel6"></td>
<td><input name="address6" type="text" id="address6"></td>
<td><input name="yewu6" type="text" id="yewu6"></td>
<td><input name="beizhu6" type="text" id="beizhu6"></td>
</tr>
<tr>
<td><input name="xm7" type="text" id="xm7"></td>
<td><select name="xb7" id="xb7">
<option>男</option>
<option>女</option>
</select></td>
<td><input name="tel7" type="text" id="tel7"></td>
<td><input name="address7" type="text" id="address7"></td>
<td><input name="yewu7" type="text" id="yewu7"></td>
<td><input name="beizhu7" type="text" id="beizhu7"></td>
</tr>
<tr>
<td><input name="xm8" type="text" id="xm8"></td>
<td><select name="xb8" id="xb8">
<option>男</option>
<option>女</option>
</select></td>
<td><input name="tel8" type="text" id="tel8"></td>
<td><input name="address8" type="text" id="address8"></td>
<td><input name="yewu8" type="text" id="yewu8"></td>
<td><input name="beizhu8" type="text" id="beizhu8"></td>
</tr>
<tr>
<td height="27"><input name="xm9" type="text" id="xm9"></td>
<td><select name="xb9" id="xb9">
<option>男</option>
<option>女</option>
</select></td>
<td><input name="tel9" type="text" id="tel9"></td>
<td><input name="address9" type="text" id="address9"></td>
<td><input name="yewu9" type="text" id="yewu9"></td>
<td><input name="beizhu9" type="text" id="beizhu9"></td>
</tr>
</table>

<input type="submit" name="Submit" value="批量添加">
<input type="reset" name="Submit2" value="重置">
</form>
</body>
</html>


处理页面

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>批量更新</title>
<style type="text/css">
<!--
.style1 {
color: #FF0000;
font-weight: bold;
}
-->
</style>
</head>

<body>

<% for i=1 to 9

call inseartinto
next

%>
<%
'end if%>
<%
sub inseartinto()
dim db,conn,connstr
db="Database/Database.mdb"
set Conn = server.CreateObject("ADODB.Connection")
connstr="provider=microsoft.jet.oledb.4.0;data source="& server.MapPath(""&db&"")
conn.Open connstr
CopyRight="<div align=center><br>版权所有:<a href='mailto:ftsj@163.com' title=''>菲特数据 </a><a href='http://www.ftsj.cn' title='powered by 菲特数据'> 翻版必究</a></div>"

dim xm,xb,tel,address,yewu,beizhu
xm=request("xm"&i)
xb=request("xb"&i)
tel=request("tel"&i)
address=request("address"&i)
yewu=request("yewu"&i)
beizhu=request("beizhu"&i)
if not xm="" then
set rs=server.createobject("adodb.recordset")
sql="select 电话 from 客户资料 where 电话='"&tel&"'"
rs.open sql,conn,1,1
if not rs.recordcount=0 then
response.write "此号码已存在,请重新输入"
else
sql="insert into 客户资料(姓名,性别,电话,地址,业务员,备注)values('"&xm&"','"&xb&"','"&tel&"','"&address&"','"&yewu&"','"&beizhu&"')"
conn.execute(sql)
conn.close
set conn=nothing
end if
end if
end sub
%>
<% response.write "9条记录已加入数据库"
%>


<a href="addall.asp" class="style1"> 继续添加</a>
</body>
</html>


网络改变了我,编程改变了我的生活
2007-09-26 20:23
快速回复:[求助]asp批量添加access数据该怎么写
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018008 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved