欢迎光临
我们一直在努力

如何用最简单的语句提交大量表单对象的值存储到数据库-ASP教程,数据库相关

建站超值云服务器,限时71元/月

如何用最简单的语句提交大量表单对象的值存储到数据库?说道这个问题可能大家经常遇到,感到很头痛,但是又没办法,只能慢慢写,笔者以提交一张应聘表单的提交为例给大家介绍如何用最简短的语句来达到目的

脚本运行通过环境环境:

iis5.0+sqlserver2000(当然也可以access2000等)

如有任何问题或建议请发email:chenxingbai@21cn.com

生成表结构的脚本

if exists (select * from dbo.sysobjects where id = object_id(n[dbo].[yingpin]) and objectproperty(id, nisusertable) = 1)

drop table [dbo].[yingpin]

go

create table [dbo].[yingpin] (

[id] [int] identity (1, 1) not null ,

[yp_ name] [varchar] (20) collate chinese_prc_ci_as null ,

[sex] [varchar] (4) collate chinese_prc_ci_as null ,

[birthday] [varchar] (15) collate chinese_prc_ci_as null ,

[health] [varchar] (10) collate chinese_prc_ci_as null ,

[hunyin] [varchar] (10) collate chinese_prc_ci_as null ,

[zhengzhi] [varchar] (10) collate chinese_prc_ci_as null ,

[xueli] [varchar] (10) collate chinese_prc_ci_as null ,

[zhicheng] [varchar] (10) collate chinese_prc_ci_as null ,

[english] [varchar] (10) collate chinese_prc_ci_as null ,

[email] [varchar] (50) collate chinese_prc_ci_as null ,

[phone] [varchar] (50) collate chinese_prc_ci_as null ,

[yp_ address] [varchar] (100) collate chinese_prc_ci_as null ,

[zip] [varchar] (10) collate chinese_prc_ci_as null ,

[colledge] [varchar] (50) collate chinese_prc_ci_as null ,

[zhuanye] [varchar] (50) collate chinese_prc_ci_as null ,

[bumen] [varchar] (50) collate chinese_prc_ci_as null ,

[gangwei1] [varchar] (50) collate chinese_prc_ci_as null ,

[gangwei2] [varchar] (50) collate chinese_prc_ci_as null ,

[x_shijian] [varchar] (500) collate chinese_prc_ci_as null ,

[x_address] [varchar] (500) collate chinese_prc_ci_as null ,

[x_zhiwu] [varchar] (500) collate chinese_prc_ci_as null ,

[g_shijian] [varchar] (500) collate chinese_prc_ci_as null ,

[g_address] [varchar] (500) collate chinese_prc_ci_as null ,

[g_zhiwu] [varchar] (500) collate chinese_prc_ci_as null ,

[h_name] [varchar] (500) collate chinese_prc_ci_as null ,

[h_guanxi] [varchar] (500) collate chinese_prc_ci_as null ,

[h_danwei] [varchar] (500) collate chinese_prc_ci_as null ,

[h_zhiwu] [varchar] (500) collate chinese_prc_ci_as null ,

[pingjia] [varchar] (500) collate chinese_prc_ci_as null ,

[shexiang] [varchar] (500) collate chinese_prc_ci_as null ,

[beizhu] [varchar] (500) collate chinese_prc_ci_as null ,

[shijian] [varchar] (50) collate chinese_prc_ci_as null

) on [primary]

go

alter table [dbo].[yingpin] with nocheck add

constraint [df_yingpin_shijian] default (getdate()) for [shijian],

constraint [pk_yingpin] primary key clustered

(

[id]

) on [primary]

go

asp脚本addyp.asp

<!–#include file="lib/config1.asp"–>

<%

if request("action")="add" then

dim str,strvalue,strname,i,str1

str="yp_name,sex,birthday,health,hunyin,zhengzhi,xueli,zhicheng,english,email,phone,yp_address,zip,colledge,zhuanye,bumen,gangwei1,gangwei2,x_shijian,x_address,x_zhiwu,g_shijian,g_address,g_zhiwu,h_name,h_guanxi,h_danwei,h_zhiwu,pingjia,shexiang,beizhu"

str1="x_shijian,x_address,x_zhiwu,g_shijian,g_address,g_zhiwu,h_name,h_guanxi,h_danwei,h_zhiwu"

strname=split(str,",")

for i=lbound(strname) to ubound(strname)

if i<>ubound(strname) then

if instr(str1,strname(i))=0 then

if trim(request.form(strname(i)))="" then

response.write "<script>alert(发生错误,请将数据填写完整!);history.back(1);</script>"

response.end()

end if

sql=sql&""&trim(request.form(strname(i)))&","

else

j=1

much=trim(request.form(cstr(strname(i)&j)))

for j=2 to 5

much=much&"|"&trim(request.form(cstr(strname(i)&j)))

next

sql=sql&""&much&","

end if

else

if trim(request.form(strname(i)))="" then

response.write "<script>alert(发生错误,请将数据填写完整!);history.back(1);</script>"

response.end()

end if

sql=sql&""&trim(request.form(strname(i)))&""

end if

next

sql="insert into yingpin ("&str&") values ("&sql&")"

conn.execute(sql)

if err <> 0 then

response.write "<script>alert(发生错误,请重新操作!);history.back(1);</script>"

else

response.write "<script>alert(已经成功提交应聘信息,\n我们会尽快和你联系!);window.location=addyp.asp;</script>"

end if

end if

%>

<!doctype html public "-//w3c//dtd html 4.01 transitional//en">

<html>

<head>

<meta http-equiv="content-type" content="text/html; charset=gb2312">

<title>gsjj</title>

<link type="text/css" rel="stylesheet" href="main.css">

</head>

<body bgcolor="#0066cc" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="background-attachment:fixed;">

   

<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>

<td align="center" valign="top" class="gray">

<p align="center"><font color="#66ff00">:::::::诚邀加盟:::::::</font></p>

<form action="addyp.asp?action=add" method="post" name="ts">

<table width=100% border=1 align="center" cellpadding=0 cellspacing="0" bordercolorlight="#000000" bordercolordark="#ffffff">

<tbody>

<tr>

<td height="35" colspan="5"><font color="#ffffff"><span

id=fps7>姓   名

<input

name="name" onfocus="this.select()"

onmouseover="this.focus()" size="12"

>

<font color="#ff0000"> *</font>  性别

<input

name="sex" onfocus="this.select()"

onmouseover="this.focus()" size="4"

type=text>

<font color="#ff0000">*</font>    出生年月

<input name="birthday"

type=text id="birthday"

onfocus="this.select()"

onmouseover="this.focus()" size="16"

>

<font color="#ff0000">*</font>  </span></font></td>

</tr>

<tr>

<td height="36" colspan="5"><font color="#ffffff"><span

id=fps7>健康状况

<input

name="health" onfocus="this.select()"

onmouseover="this.focus()" size="8"

>

<font color="#ff0000">*</font>  婚姻状况

<input

name="hunyin" onfocus="this.select()"

onmouseover="this.focus()" size="6"

type=text>

<font color="#ff0000">*</font>   政治面貌

<input

name="zhengzhi" onfocus="this.select()"

onmouseover="this.focus()" size="16"

type=text>

<font color="#ff0000">*</font> </span></font></td>

</tr>

<tr>

<td height="34" colspan="5"><font color="#ffffff">最高学历<span id=fps7>

<input

name="xueli" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

<font color="#ff0000">*</font> 职称

<input

name="zhicheng" onfocus="this.select()"

onmouseover="this.focus()" size="8"

type=text>

<font color="#ff0000">*</font>   外语水平

<input

name="english" onfocus="this.select()"

onmouseover="this.focus()" size="16"

type=text>

<font color="#ff0000">*</font> </span></font></td>

</tr>

<tr>

<td height="30" colspan="5"><font color="#ffffff">e – mail<span id=fps7>

<input

name="email" onfocus="this.select()"

onmouseover="this.focus()" size="30"

>

<font color="#ff0000">*</font> 电  话

<input

name="phone" onfocus="this.select()"

onmouseover="this.focus()" size=16

>

<font color="#ff0000">*</font> </span></font></td>

</tr>

<tr>

<td height="28" colspan="5" valign="middle"> <font color="#ffffff"><span id=fps7>联系地址</span><span id=fps7>

<input

name="address" onfocus="this.select()"

onmouseover="this.focus()" size="30"

>

<font color="#ff0000">*</font> 邮政编码

<input

name="zip" onfocus="this.select()"

onmouseover="this.focus()" size="16"

type=text>

<font color="#ff0000">*</font> </span></font></td>

</tr>

<tr>

<td height="29" colspan="5"><font color="#ffffff"> <span

id=fps7>毕业院校

<input

name="colledge" onfocus="this.select()"

onmouseover="this.focus()" size="30"

>

<font color="#ff0000">*</font> 专  业

<input

name="zhuanye" onfocus="this.select()"

onmouseover="this.focus()" size=16

>

<font color="#ff0000">*</font> </span></font></td>

</tr>

<tr>

<td height="27" colspan="5"><font color="#ffffff">应聘部门<span

id=fps7>

<input

name="bumen" onfocus="this.select()"

onmouseover="this.focus()" size=10

>

</span><span

id=fps7><font color="#ff0000">*</font></span>应聘岗位<span

id=fps7>

<input

name="gangwei1" onfocus="this.select()"

onmouseover="this.focus()" size=12

>

</span><span

id=fps7><font color="#ff0000">*</font></span>第二应聘岗位<span

id=fps7>

<input

name="gangwei2" onfocus="this.select()"

onmouseover="this.focus()" size=12

>

<font color="#ff0000">*</font> </span></font></td>

</tr>

<tr>

<td width="5%" height="203" rowspan="6" align="center" valign="middle"><font color="#ffffff">学<br>

<br>

习<br>

<br>

经<br>

<br>

历 </font></td>

<td height="25" colspan="4">     <font color="#ffffff">起止时间           学校          

  职务</font></td>

</tr>

<tr align="center">

<td colspan="4" align="left"><font color="#ffffff"><span

id=fps7>  

<input

name="x_shijian1" onfocus="this.select()"

onmouseover="this.focus()" size="18"

>

   

<input

name="x_address1" onfocus="this.select()"

onmouseover="this.focus()" size="20"

>

  

<input

name="x_zhiwu1" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

</tr>

<tr align="center">

<td colspan="4" align="left"><font color="#ffffff"><span

id=fps7> 

<input

name="x_shijian2" onfocus="this.select()"

onmouseover="this.focus()" size="18"

>

   

<input

name="x_address2" onfocus="this.select()"

onmouseover="this.focus()" size="20"

>

  

<input

name="x_zhiwu2" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

</tr>

<tr align="center">

<td colspan="4" align="left"><font color="#ffffff"><span

id=fps7> 

<input

name="x_shijian3" onfocus="this.select()"

onmouseover="this.focus()" size="18"

>

   

<input

name="x_address3" onfocus="this.select()"

onmouseover="this.focus()" size="20"

>

  

<input

name="x_zhiwu3" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

</tr>

<tr align="center">

<td colspan="4" align="left"><font color="#ffffff"><span

id=fps7> 

<input

name="x_shijian4" onfocus="this.select()"

onmouseover="this.focus()" size="18"

>

   

<input

name="x_address4" onfocus="this.select()"

onmouseover="this.focus()" size="20"

>

  

<input

name="x_zhiwu4" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

</tr>

<tr align="center">

<td colspan="4" align="left"><font color="#ffffff"><span

id=fps7> 

<input

name="x_shijian5" onfocus="this.select()"

onmouseover="this.focus()" size="18"

>

   

<input

name="x_address5" onfocus="this.select()"

onmouseover="this.focus()" size="20"

>

  

<input

name="x_zhiwu5" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

</tr>

<tr>

<td colspan="5">

</tbody>

<tr>

<td height="203" rowspan="6" align="center" valign="middle"><font color="#ffffff">工</font><font color="#ffffff"><br>

<br>

作<br>

<br>

经<br>

<br>

历 </font></td>

<td height="24" colspan="4">     <font color="#ffffff">起止时间           供职单位         

 职务</font></td>

</tr>

<tr align="center">

<td colspan="4" align="left"><font color="#ffffff"><span

id=fps7>  

<input

name="g_shijian1" onfocus="this.select()"

onmouseover="this.focus()" size="18"

>

   

<input

name="g_address1" onfocus="this.select()"

onmouseover="this.focus()" size="20"

>

  

<input

name="g_zhiwu1" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

</tr>

<tr align="center">

<td colspan="4" align="left"><font color="#ffffff"><span

id=fps7> 

<input

name="g_shijian2" onfocus="this.select()"

onmouseover="this.focus()" size="18"

>

   

<input

name="g_address2" onfocus="this.select()"

onmouseover="this.focus()" size="20"

>

  

<input

name="g_zhiwu2" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

</tr>

<tr align="center">

<td colspan="4" align="left"><font color="#ffffff"><span

id=fps7> 

<input

name="g_shijian3" onfocus="this.select()"

onmouseover="this.focus()" size="18"

>

   

<input

name="g_address3" onfocus="this.select()"

onmouseover="this.focus()" size="20"

>

  

<input

name="g_zhiwu3" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

</tr>

<tr align="center">

<td colspan="4" align="left"><font color="#ffffff"><span

id=fps7> 

<input

name="g_shijian4" onfocus="this.select()"

onmouseover="this.focus()" size="18"

>

   

<input

name="g_address4" onfocus="this.select()"

onmouseover="this.focus()" size="20"

>

  

<input

name="g_zhiwu4" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

</tr>

<tr align="center">

<td colspan="4" align="left"><font color="#ffffff"><span

id=fps7> 

<input

name="g_shijian5" onfocus="this.select()"

onmouseover="this.focus()" size="18"

>

   

<input

name="g_address5" onfocus="this.select()"

onmouseover="this.focus()" size="20"

>

  

<input

name="g_zhiwu5" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

</tr>

<tr>

<td height="190" rowspan="6" align="center" valign="middle"><font color="#ffffff">家<br>

庭<br>

成<br>

员<br>

及<br>

主<br>

要<br>

社<br>

会<br>

关<br>

系 </font></td>

<td height="23" colspan="4">   <font color="#ffffff">姓名     与本人关系       

工作单位           职务</font></td>

</tr>

<tr align="center">

<td width="17%" height="20" align="center" valign="middle"><font color="#ffffff"><span id=fps7>

<input

name="h_name1" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

<td width="19%" align="center" valign="middle"><font color="#ffffff"><span id=fps7>

<input

name="h_guanxi1" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

<td width="41%" align="center" valign="middle"><font color="#ffffff"><span id=fps7>

<input

name="h_danwei1" onfocus="this.select()"

onmouseover="this.focus()" size="28"

>

</span></font></td>

<td width="18%" align="center"><font color="#ffffff"><span id=fps7>

<input

name="h_zhiwu1" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

</tr>

<tr align="center">

<td height="20" align="center" valign="middle"><font color="#ffffff"><span

id=fps7>

<input

name="h_name2" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

<td width="19%" align="center" valign="middle"><font color="#ffffff"><span

id=fps7>

<input

name="h_guanxi2" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

<td width="41%" align="center" valign="middle"><font color="#ffffff"><span

id=fps7>

<input

name="h_danwei2" onfocus="this.select()"

onmouseover="this.focus()" size="28"

>

</span></font></td>

<td width="18%" align="center"><font color="#ffffff"><span id=fps7>

<input

name="h_zhiwu2" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

</tr>

<tr align="center">

<td height="20" align="center" valign="middle"><font color="#ffffff"><span

id=fps7>

<input

name="h_name3" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

<td width="19%" align="center" valign="middle"><font color="#ffffff"><span

id=fps7>

<input

name="h_guanxi3" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

<td width="41%" align="center" valign="middle"><font color="#ffffff"><span

id=fps7>

<input

name="h_danwei3" onfocus="this.select()"

onmouseover="this.focus()" size="28"

>

</span></font></td>

<td width="18%" align="center"><font color="#ffffff"><span id=fps7>

<input

name="h_zhiwu3" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

</tr>

<tr align="center">

<td height="20" align="center" valign="middle"><font color="#ffffff"><span

id=fps7>

<input

name="h_name4" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

<td width="19%" align="center" valign="middle"><font color="#ffffff"><span

id=fps7>

<input

name="h_guanxi4" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

<td width="41%" align="center" valign="middle"><font color="#ffffff"><span

id=fps7>

<input

name="h_danwei4" onfocus="this.select()"

onmouseover="this.focus()" size="28"

>

</span></font></td>

<td width="18%" align="center"><font color="#ffffff"><span id=fps7>

<input

name="h_zhiwu4" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

</tr>

<tr align="center">

<td height="20" align="center" valign="middle"><font color="#ffffff"><span

id=fps7>

<input

name="h_name5" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

<td width="19%" align="center" valign="middle"><font color="#ffffff"><span

id=fps7>

<input

name="h_guanxi5" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

<td width="41%" align="center" valign="middle"><font color="#ffffff"><span

id=fps7>

<input

name="h_danwei5" onfocus="this.select()"

onmouseover="this.focus()" size="28"

>

</span></font></td>

<td width="18%" align="center"><font color="#ffffff"><span id=fps7>

<input

name="h_zhiwu5" onfocus="this.select()"

onmouseover="this.focus()" size="10"

>

</span></font></td>

</tr>

<tr>

<td align="center"><font color="#ffffff">自<br>

<br>

我<br>

<br>

评<br>

<br>

价 </font>

<td colspan="4" align="center"><textarea name="pingjia" cols="60" rows="5"></textarea>

<font color="#ffffff"><span

id=fps7><font color="#ff0000">*</font></span></font> <tr>

<td height="24" colspan="5"><font color="#ffffff">对未来工作的设想或其它需要补充的内容

:</font>

<tr align="center">

<td colspan="5"> <textarea name="shexiang" cols="60" rows="5"></textarea>

<font color="#ffffff"><span

id=fps7><font color="#ff0000">*</font></span></font> <tr>

<td height="28" colspan="5"><font color="#ffffff">备注(工作地点、薪金期望等):

</font>

<tr align="center">

<td colspan="5"><textarea name="beizhu" cols="60" rows="5"></textarea>

<font color="#ffffff"><span

id=fps7><font color="#ff0000">*</font></span></font> <tr>

<td colspan="5"><font color="#ffffff">&nbsp;</font>

<tr align="center">

<td height="23" colspan="5"><font color="#ffffff"><span id=fps7>

<input name="button" type="submit" value="提交">

        

<input name="reset" type="reset" value="重新填写">

</span></font>

</table>

<br>

<br>

</form>

</td>

</tr>

</table>

</body>

</html>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 如何用最简单的语句提交大量表单对象的值存储到数据库-ASP教程,数据库相关
分享到: 更多 (0)