asp批量添加记录程

来源:互联网 发布:sql数据库置疑修复 编辑:程序博客网 时间:2024/05/22 06:24

表单部分

<!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>
       < lect></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>
       < lect></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>
       < lect></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>
       < lect></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>
       < lect></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>
       < lect></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>
       < lect></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>
       < lect></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>
       < lect></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>
 

原创粉丝点击