PC6下载站

分类分类

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

关注+2004-10-07作者:蓝点


            
             
              
             
            

               
               

            



            如何用最简单的语句提交大量表单对象的值存储到数据库?说道这个问题可能大家经常遇到,感到很头痛,但是又没办法,只能慢慢写,笔者以提交一张应聘表单的提交为例给大家介绍如何用最简短的语句来达到目的
脚本运行通过环境环境:
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




<%
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 ""
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 ""
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 ""

else
response.write ""

end If
end if
%>




gsjj




   





:::::::诚邀加盟:::::::












































































































id=fps7>姓   名
name="name" onFocus="this.select()"
onMouseOver="this.focus()" size="12"
>
*  性别
name="sex" onFocus="this.select()"
onMouseOver="this.focus()" size="4"

type=text>
*    出生年月
type=text id="birthday"
onFocus="this.select()"
onMouseOver="this.focus()" size="16"
>
* 
id=fps7>健康状况
name="health" onFocus="this.select()"
onMouseOver="this.focus()" size="8"
>
*  婚姻状况
name="hunyin" onFocus="this.select()"
onMouseOver="this.focus()" size="6"

type=text>
*   政治面貌
name="zhengzhi" onFocus="this.select()"
onMouseOver="this.focus()" size="16"

type=text>
*
最高学历
name="xueli" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
* 职称
name="zhicheng" onFocus="this.select()"
onMouseOver="this.focus()" size="8"

type=text>
*   外语水平
name="english" onFocus="this.select()"
onMouseOver="this.focus()" size="16"

type=text>
*
E - MAIL
name="email" onFocus="this.select()"
onMouseOver="this.focus()" size="30"
>
* 电  话
name="phone" onFocus="this.select()"
onMouseOver="this.focus()" size=16
>
*
联系地址
name="address" onFocus="this.select()"
onMouseOver="this.focus()" size="30"
>
* 邮政编码
name="zip" onFocus="this.select()"
onMouseOver="this.focus()" size="16"

type=text>
*
id=fps7>毕业院校
name="colledge" onFocus="this.select()"
onMouseOver="this.focus()" size="30"
>
* 专  业
name="zhuanye" onFocus="this.select()"
onMouseOver="this.focus()" size=16
>
*
应聘部门id=fps7>
name="bumen" onFocus="this.select()"
onMouseOver="this.focus()" size=10
>
id=fps7>*应聘岗位id=fps7>
name="gangwei1" onFocus="this.select()"
onMouseOver="this.focus()" size=12
>
id=fps7>*第二应聘岗位id=fps7>
name="gangwei2" onFocus="this.select()"
onMouseOver="this.focus()" size=12
>
*












     起止时间           学校          
  职务
id=fps7>  
name="x_shijian1" onFocus="this.select()"
onMouseOver="this.focus()" size="18"
>
   
name="x_address1" onFocus="this.select()"
onMouseOver="this.focus()" size="20"
>
  
name="x_zhiwu1" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
id=fps7> 
name="x_shijian2" onFocus="this.select()"
onMouseOver="this.focus()" size="18"
>
   
name="x_address2" onFocus="this.select()"
onMouseOver="this.focus()" size="20"
>
  
name="x_zhiwu2" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
id=fps7> 
name="x_shijian3" onFocus="this.select()"
onMouseOver="this.focus()" size="18"
>
   
name="x_address3" onFocus="this.select()"
onMouseOver="this.focus()" size="20"
>
  
name="x_zhiwu3" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
id=fps7> 
name="x_shijian4" onFocus="this.select()"
onMouseOver="this.focus()" size="18"
>
   
name="x_address4" onFocus="this.select()"
onMouseOver="this.focus()" size="20"
>
  
name="x_zhiwu4" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
id=fps7> 
name="x_shijian5" onFocus="this.select()"
onMouseOver="this.focus()" size="18"
>
   
name="x_address5" onFocus="this.select()"
onMouseOver="this.focus()" size="20"
>
  
name="x_zhiwu5" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>













     起止时间           供职单位         
 职务
id=fps7>  
name="g_shijian1" onFocus="this.select()"
onMouseOver="this.focus()" size="18"
>
   
name="g_address1" onFocus="this.select()"
onMouseOver="this.focus()" size="20"
>
  
name="g_zhiwu1" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
id=fps7> 
name="g_shijian2" onFocus="this.select()"
onMouseOver="this.focus()" size="18"
>
   
name="g_address2" onFocus="this.select()"
onMouseOver="this.focus()" size="20"
>
  
name="g_zhiwu2" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
id=fps7> 
name="g_shijian3" onFocus="this.select()"
onMouseOver="this.focus()" size="18"
>
   
name="g_address3" onFocus="this.select()"
onMouseOver="this.focus()" size="20"
>
  
name="g_zhiwu3" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
id=fps7> 
name="g_shijian4" onFocus="this.select()"
onMouseOver="this.focus()" size="18"
>
   
name="g_address4" onFocus="this.select()"
onMouseOver="this.focus()" size="20"
>
  
name="g_zhiwu4" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
id=fps7> 
name="g_shijian5" onFocus="this.select()"
onMouseOver="this.focus()" size="18"
>
   
name="g_address5" onFocus="this.select()"
onMouseOver="this.focus()" size="20"
>
  
name="g_zhiwu5" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>






























   姓名     与本人关系       
工作单位           职务

name="h_name1" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>

name="h_guanxi1" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>

name="h_danwei1" onFocus="this.select()"
onMouseOver="this.focus()" size="28"
>

name="h_zhiwu1" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
id=fps7>
name="h_name2" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
id=fps7>
name="h_guanxi2" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
id=fps7>
name="h_danwei2" onFocus="this.select()"
onMouseOver="this.focus()" size="28"
>

name="h_zhiwu2" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
id=fps7>
name="h_name3" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
id=fps7>
name="h_guanxi3" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
id=fps7>
name="h_danwei3" onFocus="this.select()"
onMouseOver="this.focus()" size="28"
>

name="h_zhiwu3" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
id=fps7>
name="h_name4" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
id=fps7>
name="h_guanxi4" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
id=fps7>
name="h_danwei4" onFocus="this.select()"
onMouseOver="this.focus()" size="28"
>

name="h_zhiwu4" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
id=fps7>
name="h_name5" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
id=fps7>
name="h_guanxi5" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>
id=fps7>
name="h_danwei5" onFocus="this.select()"
onMouseOver="this.focus()" size="28"
>

name="h_zhiwu5" onFocus="this.select()"
onMouseOver="this.focus()" size="10"
>














id=fps7>*
对未来工作的设想或其它需要补充的内容


id=fps7>*
备注(工作地点、薪金期望等):


id=fps7>*
&nbsp;


        















展开全部

相关文章

更多+相同厂商

热门推荐

  • 最新排行
  • 最热排行
  • 评分最高
排行榜

    点击查看更多

      点击查看更多

        点击查看更多

        说两句网友评论

          我要评论...
          取消