当前位置: 首页 > 图文教程 > 网络编程 > ASP > 用ASP开发试题库与在线考试系统(8)

ASP
利用ASP输出excel文件一例
asp中使用js的encodeURIComponent
ASP动态网站制作中使用MYSQL的分析
如何编写通用的ASP防SQL注入攻击程序
ASP脚本变量、函数、过程和条件语句
ASP内建对象Application和Session
ASP基础教程:常用的 ASP ActiveX 组件
ASP程序漏洞解析及黑客入侵防范方法
ASP访问带多个参数的存储过程
用ASP和SQL语句动态的创建Access表
ASP初学者学习ASP指令
ASP开发中有用的函数(function)集合(1)
ASP开发中有用的函数(function)集合(2)
ASP开发中有用的函数(function)集合(3)
ASP网站程序自动升级实现的方法
ASP开发中的(VBScript)类基础学习
ASP代码:防止重复多次提交表单的方法
在ASP中使用类,实现模块化
ASP基础教程之学习ASP中子程序的应用
ASP技巧:ASP中三个常用语句的使用技巧

用ASP开发试题库与在线考试系统(8)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 26 ::
收藏到网摘: n/a

    七、附录:源程序列表

  由于源代码繁多,限于篇幅,无法一一列举,现只公布部分代码,具体以系统实物为准。下面是录入试题.asp文件:

<script language="VBScript">
<!-- 'Written by HeKai 2001
Function datacheck()'确保前台输入数据合法
 dim errflag, msg
 errflag = True
 if Len(Trim(luru.xzsj.value)) = 0 Then
  focusto(1); errflag = false; msg="请输入 '选自书籍名称'"
 ElseIf Len(Trim(luru.stnr.value)) = 0 Then
  focusto(9); errflag = false; msg=" '试题内容' 呢"
 ElseIf Len(Trim(luru.A.value)) = 0 Then
  focusto(10); errflag = false; msg=" '答案_A' 呢"
   ┋ ┋ ┋
 ElseIf Len(Trim(luru.F.value)) = 0 Then
  focusto(15); errflag = false; msg="请还原成默认值"
 End if
 If (errflag = false) then
  msg = msg & vbCRLF
  MsgBox msg, 64, "提示"
  Exit Function
 End if
  datacheck = errflag; luru.Submit
End Function

Sub focusto(x)'将鼠标定位在出错处
document.luru.elements(x).focus()
End Sub
--></script>

  以下是录入试题.inc文件:

<script Language="VBScript" RunAt="Server">
 Function check_Pass()'检查库中是否已有此数据
  kmxxmc = Request.Form("kmxxmc")
  stbh = Request.Form("stbh") stnr = Request.Form("stnr")
  SQLstr = "select * from " & kmxxmc & " where stbh=" & "'" & stbh & "'"
  SQLstr = SQLstr & " or tmnr=" & "'" & stnr & "'"
  set adocon=Server.CreateObject("ADODB.Connection")
  adocon.Open "zxtest"
  set sa1=adocon.Execute(SQLstr)
  If sa1.EOF Then
   check_Pass = False
  Else
   check_Pass = True
  End If
  sa1.Close adocon.Close
End Function

Sub Add_Comment()'开始插入数据并显示出来
 Dim kmxxmc,xzsj,tmlx,nycd,jxyq,stbh,stnr
 Dim A,B,C,D,E,F,bzda,lrz,Picstr,SQLstr,lr_date,zhang,jie
 kmxxmc = Request.Form("kmxxmc") xzsj = Request.Form("xzsj")
  ┋ ┋ ┋
 bzda = Request.Form("bzda") zhang = Request.form("zhang")
 set adocon=Server.CreateObject("ADODB.Connection")
 adocon.Open "zxtest"
 SQLstr = "insert into " & kmxxmc & " (xzsj,tmlx,tmnd,jxyq,stbh,tmnr,  bxda_a,"
 SQLstr = SQLstr & ",jie,lrz) values (" & "'" & xzsj & "'," & "'" & tmlx & "',"
  ┋ ┋ ┋
 SQLstr = SQLstr & "'," & "'" & date & "'," & "'" & zhang & "'," & "'" & jie & "'," SQLstr = SQLstr & "'" & lrz & "')"
 set sa1 = adocon.Execute(SQLstr)
 Picstr="<img src="/upload/tech/20091103/20091103101727_fae0b27c451c728867a567e8c1bb4e53.jpg">"
 Response.Write "恭喜!此为<i> " & lrz & "</i> 刚才录入的试题"
 Response.Write Picstr & " 试题编号:" & stbh
 Response.Write "试题内容:" & stnr & "<br>"
 Response.Write "答案_A:" & A & "<br>"
  ┋ ┋ ┋
 adocon.Close
End Sub

Sub Register()
 If check_Pass() Then '如果库中已有的话,则给出提示信息
  Show_Warning()
 Else '否则添加进去
  Add_Comment()
 End If
End Sub

Sub Show_Warning()'给出提示信息的函数
 Response.Write("<p>")
 Response.Write("<center>很抱歉<p>")
 Response.Write("库中已有此试题编号或试题内容,请返回前页修改!")
 Response.Write("</center>")
 Response.Write("Made by hekai himself in 2001")
End Sub
</script>

此为"检索试题"的程序代码:
<script Language="VBScript" RunAt="Server">
Function a