日期:2013-06-03  浏览次数:21154 次

<%@ 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>学号: