欢迎光临
我们一直在努力

网络考场(8)(转)taddstudent.asp

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

<%@ language=vbscript %>
<html>
<head>
<meta name="generator" content="microsoft visual studio 6.0">
</head>
<body>
<%
if request.servervariables("http_method")="post" and request.form("submit")<>"跳到" then
    如果按post方式提交表单内容
    set conn=server.createobject("adodb.connection")
    conn.connectionstring="dsn=testsys"
    conn.open
    strstid=request.form("stid")
    strstname=request.form("stname")
    if request.form("submit")="加入" then
    如果执行加入学生信息的请求
        strsql="select * from studentinfo where stid=" & strstid & ""
        根据要加入的学生学号查询数据库的表studentinfo中是否存在该学生的记录
        set mrs1=conn.execute(strsql)
        if  not(mrs1.bof and  mrs1.eof) then
        如果要加入的学生学号已存在,则提示重新输入信息        
            response.write "该学号已经存在,请重新输入学生信息<br>"
            response.write "<a href=taddstudent.asp?page=" & request("page") & "&stname=" & strstname & "&stid=" & strstid & ">返回</a>"
        else
        如果要加入的学生学号不存在,则向数据库中加入该学生信息    
        strsql="insert into studentinfo (stname,stid) values (" & strstname & "," & strstid & ")"
        conn.execute(strsql)
        strstid=""
        strstname=""
        end if
    end if
    if request.form("submit")="删除" then
    如果是删除学生信息请求
        strsql="delete * from studentinfo where stid=" & strstid & ""
        删除学生信息
        conn.execute(strsql)
        删除学生的考试成绩
        strsql="delete * from score where stid=" & strstid & ""
        conn.execute(strsql)
        strstid=""
        strstname=""
    end if
    conn.close
    set conn=nothing
    else
        strstname=request.querystring("stname")
        strstid=request.querystring("stid")
end if
%>
<form action="taddstudent.asp" method=post id=form1 name=form1>
<p><font face="幼圆" size=3 color=crimson>学生信息</font><br>
<font face="" size=3>姓名:
<input id=stname name=stname value=<%=strstname%>></font><br>
<font face="" size=3>学号:
<input id=stid name=stid value=<%=strstid%>></font>
<font face="" size=3> 
<input id=submit1 name=submit type=submit value=加入>
<input id=submit2 name=submit type=submit value=删除>
</font></p><font face="" size=3>
<hr>
</font>
<p>
<table border=0 cellpadding=1 cellspacing=1 width=75%>
    <tr bgcolor=honeydew>
        <td>姓名</td>
        <td>学号</td></tr>
<%
set mrs=server.createobject("adodb.recordset")
mrs.activeconnection="dsn=testsys"
mrs.source="select * from studentinfo"
mrs.open ,,1,3
以下是分页显示学生的姓名与学号
if not mrs.bof and not mrs.eof then
    mrs.pagesize=5
    if request("page")<>"" then
        page=cint(request("page"))
    else
        page=1
    end if
    mrs.absolutepage=page
    for i=1 to mrs.pagesize
        if mrs.eof then
            exit for
        end if
        response.write "<tr><td>"
        显示学生的姓名,并提供连接,点击该连接,
        在taddstudent.asp中的文本框中显示该学生的姓名和学号
        response.write "<a href=taddstudent.asp?stname="& mrs("stname") & "&stid=" & mrs("stid") & "&page=" & page & ">" & mrs("stname") & "</a>"
        response.write "</td>"
        显示学生的学号
        response.write "<td>" & mrs("stid") & "</td></tr>"
        mrs.movenext
    next
end if
%>
</table>
</p>
<p>
<input id=button1 name=submit type=submit value=跳到>
<input id=page name=page
style="height: 21px; width: 46px" value=<%=request("page")%>>页/共<%=mrs.pagecount%>页
<%
if page>1 then
    当前页不是是第一页则提供上一页的连接
    response.write "<a href=taddstudent.asp?page=" & page-1 & ">上一页</a>|"
else
    否则不提供上一页的连接
    response.write "上一页|"
end if
if page<mrs.pagecount then
    当前页是最后一页则提供下一页连接
    response.write "<a href=taddstudent.asp?page=" & page+1 & ">下一页</a>"
else
    否则不提供下一页连接
    response.write "下一页"
end if
关闭数据库的recordset对象
mrs.close
set mrs=nothing
%>
</p>
</form>
</body>
</html>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 网络考场(8)(转)taddstudent.asp
分享到: 更多 (0)

相关推荐

  • 暂无文章