分享
 
 
 

如何用最简单的语句提交大量表单对象的值存储到数据库

王朝asp·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

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

脚本运行通过环境环境:

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

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

生成表结构的脚本

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[yingpin]') and OBJECTPROPERTY(id, N'IsUserTable') = 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>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有