<
您还没有登录┊登录注册 当前在线:432
源码程序系统工具编程开发图形图像网络软件应用软件多媒体类娱乐休闲驱动程序各类教程各类论文文章阅读
ASPPHPJSPASP.NETVBVF百度搜索星星练题网络文摘股市消息技能习题详细分类
当前位置:首页 \ 各类教程 \ 计算机
站内搜索


ASP批量导入数据

文件大小:10 k
运行平台:Windows9X/ME/NT/2000/XP
级别评定:
添加时间:2010-11-12 9:06:00
最后更新:2010-11-12 9:06:00
相关链接:无
所需金额:0 元
添加者:管理员

Download.1

/ ::软件简介:: / ::相关软件:: / ::软件点评:: /::上一个::/ ::下一个:: /
管理首页
ASP批量导入数据 原理:就是用一个FOR循环朝数据库里面插入数据,但是过程比较复杂,但是用到数据库的存储过程的时候要用到事务,以防止插入过程中数据出错。 stuinput2.asp 页面部分: <%option explicit%> <% dim schname,classname,classid,schid schname="" classname="" classid="" schid="" schname=ubb(request.querystring("schname")) classname=ubb(request.querystring("classname")) classid=ubb(request.querystring("classid")) schid=ubb(request.querystring("schid")) %> 导入学生
学校:<%=schname%>  班级:<%=classname%>
           

 注意:此部分数据导入只对职校学生,请慎重导入,以免出错。导入学生时,必须按照下列格式,第一列为学生编号,第二列为学生手机;复制时只需要复制像格式中的蓝色区域!
(重复的号码只能导入一次,若有一号多个学生的只能一一添加)
学生编号
学生手机
108309**** 1345******
108309**** 1345******
108309**** 1345******
数据处理及提交部分: <%option explicit%> <% Dim examsco,schid,returnvalue,temp,i,templist2,stuid,stuname,stumobile,stumobilelist,stumobile2,studentid,classid,k,errormsg,noinnum,errormobnum,errstunum,schname,classname classid="" examsco="" schid="" schname="" classname="" 'Response.Write("1111") examsco=ubb(Request.Form("txta_examsco")) schid=ubb(Request.Form("hid_schid")) classid=ubb(Request.Form("hid_classid")) schname=ubb(Request.Form("hid_schname")) classname=ubb(Request.Form("hid_classname")) if examsco="" then response.write("") response.End End if examsco=replace(examsco,chr(13) & chr(10),"|@|") examsco=replace(examsco," ","|#|") examsco=replace(examsco,"'","") examsco=examsco&"|#||@|" 'Response.Write(examsco) 'response.End returnvalue="" returnvalue=checkdate(examsco) if returnvalue="1" then response.write("") response.end elseif returnvalue="2" then response.write("") response.end elseif returnvalue="3" then response.write("") response.end end if temp=split(examsco,"|@|") '分行 for i=0 to ubound(temp)-1 templist2=split(temp(i),"|#|")'分字段 stuid="" stuname="" stumobile="" stuid=trim(templist2(0)) stumobile=trim(templist2(1)) if stumobile<>"" then if right(stumobile,1)="/" then stumobile=left(stumobile,len(stumobile)-1) end if stumobilelist="" stumobilelist=split(stumobile,"/") if ubound(stumobilelist)=0 then '如果为一个号码时 stumobile2="" stumobile2=stumobile if len(stumobile2)=8 then stumobile2="0512"&stumobile2 end if if isnull(studentid) or studentid="" then returnvalue="" returnvalue=addstudent(stuid,stumobile2,schid) if returnvalue="0" then k=k+1 elseif returnvalue="9" then noinnum=noinnum+1 elseif returnvalue="6" then errormobnum=errormobnum+1 else errstunum=errstunum+1 end if else returnvalue="" returnvalue=addmobile(studentid,stumobile2) 'response.write("
returnvalue1=" & returnvalue & "
") if returnvalue<>"0" then noinnum=noinnum+1 'response.write("") 'exit for 'response.end end if end if else '多个号码 for j=0 to ubound(stumobilelist) stumobile2="" stumobile3="" stumobile2=stumobilelist(j) stumobile3=stumobilelist(0) if len(stumobile3)=8 then stumobile3="0512"&stumobile3 if len(stumobile2)=8 then stumobile2="0512"&stumobile2 end if 'response.write("sdf"&stumobile2) studentid="" 'response.write("classid="&classid&"stumobile2="&stumobile2) studentid=getstudentid(classid,stumobile3) 'studentid=getstudentid("17862","13913568488") 'response.write("studentid="&studentid&"
") if isnull(studentid) or studentid="" then returnvalue="" returnvalue=addstudent(stuid,stuname,stuphone,stumobile2,classid) 'response.write("
returnvalue=" & returnvalue & "
") 'response.write(stumobile2) 'response.end if returnvalue="0" then k=k+1 elseif returnvalue="9" then noinnum=noinnum+1 elseif returnvalue="6" then errormobnum=errormobnum+1 'else 'response.write("") 'exit for 'response.end else errstunum=errstunum+1 end if else returnvalue="" returnvalue=addmobile(studentid,stumobile2) 'response.write("
returnvalue1=" & returnvalue & "
") if returnvalue<>"0" then noinnum=noinnum+1 'response.write("") 'exit for 'response.end end if end if next 'response.end end if else returnvalue="" returnvalue=addstudent(stuid,stuname,stuphone,stumobile,classid) 'response.write("
returnvalue=" & returnvalue & "
") if returnvalue="0" then k=k+1 elseif returnvalue="9" then noinnum=noinnum+1 elseif returnvalue="6" then errormobnum=errormobnum+1 'else 'response.write("") 'exit for 'response.end else errstunum=errstunum+1 'errstunum="dssss" end if end if next 'response.write("共有"&k&"条记录导入数据库!") errormsg="" if k>0 then errormsg="成功导入"&k&"条学生记录\n" end if 'if noinnum<>"0" then 'errormsg=errormsg & "有"&noinnum&"条学生或号码记录原来已经存在于本校,本次不能导入\n" 'end if if errormobnum>0 then errormsg=errormsg & "有无效号码"&errormobnum&"个未能导入\n" end if if errstunum>0 then errormsg=errormsg & "有"&errstunum&"个学生导入失败\n" end if response.write("") %> <% function checkdate(scotext) dim chk_templist,chk_templist1 dim chk_stuid,chk_stumobile dim chk_moblist dim chk_i chk_templist=split(scotext,"|@|") for i=0 to ubound(chk_templist)-1 chk_templist1=split(chk_templist(i),"|#|") if ubound(chk_templist1)<1 then checkdate="1" exit for else chk_stuid="" chk_stumobile="" chk_stuid=trim(chk_templist1(0)) chk_stumobile=trim(chk_templist1(1)) if isnumeric(chk_stuid)=false then checkdate="2" exit for else if chk_stumobile<>"" then if right(chk_stumobile,1)="/" then chk_stumobile=left(chk_stumobile,len(chk_stumobile)-1) end if if instr(chk_stumobile,"/")>0 then chk_moblist=split(chk_stumobile,"/") for chk_i=0 to ubound(chk_moblist) if len(chk_moblist(chk_i))=8 then chk_moblist(chk_i)="0512"&chk_moblist(chk_i) end if '-------------------------------------------------- 'if len(chk_moblist(chk_i))="11" and left(chk_moblist(chk_i),3)="512" then ' chk_moblist(chk_i)="0"&chk_moblist(chk_i) 'end if '---------------------------------------------------- if checkmobile(chk_moblist(chk_i))="bad" then checkdate="3" exit for else checkdate="0" end if next else if len(chk_stumobile)=8 then chk_stumobile="0512"&chk_stumobile end if '------------------------------------------ 'if len(chk_stumobile)=11 and left(chk_stumobile,3)="512" then ' chk_stumobile="0"&chk_stumobile 'end if '--------------------------------------------- if checkmobile(chk_stumobile)="bad" then checkdate="3" exit for else checkdate="0" end if end if else checkdate="0" end if end if end if next end Function function addstudent(stuid,stumobile,schid) 'Response.Write(stuid) 'Response.End dim fun_returnvalue set cmd=Server.CreateObject("ADODB.Command") cmd.ActiveConnection = connstr cmd.commandtext="dbo.jxt_stumobile_insert" cmd.commandtype=4 cmd.parameters.append cmd.createparameter("@schid",adinteger,adparaminput,4,schid) cmd.parameters.append cmd.createparameter("@studentid",advarchar,adparaminput,15,stuid) cmd.parameters.append cmd.createparameter("@mobile",advarchar,adparaminput,20,stumobile) cmd.parameters.append cmd.createparameter("@Ret",adinteger,adparamoutput) cmd.execute() fun_returnvalue="" fun_returnvalue=cmd.parameters("@Ret").value set cmd=nothing if fun_returnvalue="0" then call logopera(session("se_userid"),"stuinput2.asp","stuinput2_action.asp",session("se_userid")&"给"&classid&"导入职校学生手机号码!") ElseIf fun_returnvalue="1" then Response.Write("") Response.End ElseIf fun_returnvalue="2" Then Response.Write("") Response.End ElseIf fun_returnvalue="3" Then Response.Write("") Response.End ElseIf fun_returnvalue="4" Then Response.Write("") Response.End end if addstudent=fun_returnvalue end function %> 存储过程 ALTER PROCEDURE [dbo].[jxt_stumobile_insert] @schid int, @studentid nvarchar(15), @mobile nvarchar(20), @ret int output as begin declare @status int begin if dbo.FC_CheckMobileType(@mobile)='yd' begin set @status=12 end else if dbo.FC_CheckMobileType(@mobile)='lt' begin set @status=22 end else if dbo.FC_CheckMobileType(@mobile)='xlt' begin set @status=32 end else if dbo.FC_CheckMobileType(@mobile)='cdma' begin set @status=52 end end if not exists(select top 1 * from jxt_student where studentid=''+@studentid+'') begin set @ret=1 --学生编号不存在 end else if len(@studentid)<>10 begin set @ret=2 --学生编号长度不正确 end else if len(@mobile) not in('11','12') begin set @ret=3 --手机号码不正确 end else if exists(select * from Jxt_Student_Mobile where studentid=@studentid and mobile=@mobile) begin set @ret=4 --该条数据已经存在 end else begin begin transaction insert into Jxt_Student_Mobile (studentid,mobile,status,[path],schid) values(@studentid,@mobile,@status,@status,@schid) if @@error<>0 begin rollback transaction set @ret=5 --数据插入成功 end set @ret=0 commit transaction end end
相关软件
·**备案号批量查询1.0
·**Pr值批量查询系统v1.0
·CFUpdate批量上传组件forASPv1.1.3
·文件批量上传客户端免费组件 v1.0.7 for asp
·ASP在线版批量字符替换工具
·**备案批量查询程序
·文件批量上传客户端免费组件 v1.0.6 for asp
·文件批量上传客户端免费组件 v1.0.2
·文件批量上传客户端免费组件 v1.0.1
·ASP数据库字串批量替换工具 v1.0 for sql access


1分 0
2分 0
3分 0
4分 0
5分 0
共有 0 人打分
平均得分:0


按字符查询:ABCDEFGHIJKLMNOPQRSTUVWXYZ0~9中文
下载图示: - 附汉化补丁 - 附注册 - 会员软件 - 推荐 - 最新添加
Rainight, 星旺坡 联网备案号:41092802000212 豫ICP备19032584号-1 页面执行时间: 0.13秒
业务QQ:80571569 手机:13030322310