📄 adminsavestd.asp
字号:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<!--#include file="function.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<p>
<%
dim sql
dim action
dim stuno,stuname,studepart,stumajor,stuenter,password
action=request.QueryString("action")
stuno=request.Form("stuno")
stuname=request.Form("stuname")
studepart=request.Form("studepart")
stumajor=request.Form("stumajor")
stuenter=request.Form("stuenter")
password=request.Form("password")
if action="add" then
'*******************************添加部分
set rs=server.CreateObject("adodb.recordset")
sql="select * from student where stuno='" & stuno & "'"
rs.open sql,conn,1,1
if rs.bof and rs.eof then
'添加学生信息
sql="insert into student(stuno,stuname,studepartment,stumajor,stuenter,pwd) values('" & stuno & "','" & stuname & "','" & studepart & "','" & stumajor & "','" & stuenter & "','" & password & "')"
'response.write(sql)
'response.end()
conn.execute(sql)
response.Write("添加成功")
else
response.Write("学号已经被注册!")
end if
elseif action="modify" then
'*******************************修改部分
id=request.Form("id")
set rs=server.CreateObject("adodb.recordset")
sql="select * from student where stuno='" & stuno & "' and stuid<>" & id
'response.Write(sql)
'response.End()
rs.open sql,conn,1,1
if rs.bof and rs.eof then
'修改学生信息
sql="update student set stuno='" & stuno & "',stuname='" & stuname & "',studepartment='" & studepart & "',stumajor='" & stumajor & "', stuenter='" & stuenter & "',pwd='" & password & "' where stuid=" & id
'response.Write(sql)
conn.execute sql
response.Write("修改成功")
else
response.Write("学号已经被注册!")
end if
elseif action="del" then
'*******************************删除部分
id=request.QueryString("id")
set rs=server.CreateObject("adodb.recordset")
sql="select * from student where stuid=" & id
rs.open sql,conn,1,1
if rs.bof and rs.eof then
response.Write("错误,没有需要删除学生的信息!")
else
sql="delete * from student where stuid=" & id
conn.execute(sql)
response.write("删除成功")
end if
end if
%>
<a href="adminliststd.asp">返回学生列表</a>
</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -