请教高手帮我看一下这个删除代码,为什么删除成功了但是数据库里面没有数据删除 20
deleted.jsp<%@pagecontentType="text/html;charset=gb2312"%><%@pageimport="java.sql.*"%...
deleted.jsp
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<style type="text/css">
<!--
.STYLE1 {font-size: x-large}
-->
</style>
<body>
<table width="519" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<!--DWLayoutTable-->
<tr>
<td width="761" height="89" valign="top"><div align="center">
<p class="STYLE1 STYLE1"> 欢迎使用学生管理系统!</p>
</div>
<div align="center"></div></td>
</tr>
</table>
<br>
<table width="534" height="173" border="1" align="left">
<!--DWLayoutTable-->
<tr><td height="44" colspan="8" align="center" valign="top" bgcolor="#FFFFFF" ><strong>学生管理信息</strong></td>
<tr >
<td width="73" align="center">是否删除</td>
<td width="46" align="center">学号</td>
<td width="55" align="center">姓名</td>
<td width="55" align="center">性别</td>
<td width="58" align="center">年龄</td>
<td width="65" align="center">所在系</td>
<td width="68" align="center">联系方式</td>
<td width="62" align="center">年级</td>
</tr>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:xs");
Statement stmt=con.createStatement();
String sql="select * from student";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
<tr>
<td ><div align="center"><a href="deleteUser2.jsp?id=<%=rs.getString("id")%>">删除</a></div></td>
<td><%=rs.getString("sno")%></td>
<td><%=rs.getString("sname")%></td>
<td><%=rs.getString("ssex")%></td>
<td><%=rs.getLong("sage")%></td>
<td><%=rs.getString("sdept")%></td>
<td><%=rs.getLong("sconnection")%></td>
<td><%=rs.getLong("nianji")%></td>
</tr>
<%}%>
<%
rs.close();
stmt.close();
con.close();
%>
</table>
</body>
</html>
deleteUser2.jsp
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.sql.*" %>
<%//接收要删除的学生学号
long sno;
try{
sno=Long.parseLong(request.getParameter("sno"));
}catch(Exception e){
sno=0;
}
%>
<%//构造删除记录SQL语句
String sqlString=null;//SQL语句
if(sno!=0) {//接收到的参数正确
sqlString="delete from student where sno="+sno;
//执行SQL语句
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:xs");
Statement sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
sql.executeUpdate(sqlString);
con.close();
} catch(SQLException e1) {
out.print(e1);
}
}
%>
<head>
<title>删除学生信息程序</title>
</head>
<body>
<center>
<table border="1" width="700">
<tr>
<td width="100%" colspan="2" align="center">删除学生信息程序</td>
</tr>
<tr>
<td width="100%" colspan="2">删除信息成功!</td>
</tr>
</table>
</center>
<a href="delete1.jsp">返回学生信息</a>
</body>
</html> 展开
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<style type="text/css">
<!--
.STYLE1 {font-size: x-large}
-->
</style>
<body>
<table width="519" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<!--DWLayoutTable-->
<tr>
<td width="761" height="89" valign="top"><div align="center">
<p class="STYLE1 STYLE1"> 欢迎使用学生管理系统!</p>
</div>
<div align="center"></div></td>
</tr>
</table>
<br>
<table width="534" height="173" border="1" align="left">
<!--DWLayoutTable-->
<tr><td height="44" colspan="8" align="center" valign="top" bgcolor="#FFFFFF" ><strong>学生管理信息</strong></td>
<tr >
<td width="73" align="center">是否删除</td>
<td width="46" align="center">学号</td>
<td width="55" align="center">姓名</td>
<td width="55" align="center">性别</td>
<td width="58" align="center">年龄</td>
<td width="65" align="center">所在系</td>
<td width="68" align="center">联系方式</td>
<td width="62" align="center">年级</td>
</tr>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:xs");
Statement stmt=con.createStatement();
String sql="select * from student";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
<tr>
<td ><div align="center"><a href="deleteUser2.jsp?id=<%=rs.getString("id")%>">删除</a></div></td>
<td><%=rs.getString("sno")%></td>
<td><%=rs.getString("sname")%></td>
<td><%=rs.getString("ssex")%></td>
<td><%=rs.getLong("sage")%></td>
<td><%=rs.getString("sdept")%></td>
<td><%=rs.getLong("sconnection")%></td>
<td><%=rs.getLong("nianji")%></td>
</tr>
<%}%>
<%
rs.close();
stmt.close();
con.close();
%>
</table>
</body>
</html>
deleteUser2.jsp
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.sql.*" %>
<%//接收要删除的学生学号
long sno;
try{
sno=Long.parseLong(request.getParameter("sno"));
}catch(Exception e){
sno=0;
}
%>
<%//构造删除记录SQL语句
String sqlString=null;//SQL语句
if(sno!=0) {//接收到的参数正确
sqlString="delete from student where sno="+sno;
//执行SQL语句
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:xs");
Statement sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
sql.executeUpdate(sqlString);
con.close();
} catch(SQLException e1) {
out.print(e1);
}
}
%>
<head>
<title>删除学生信息程序</title>
</head>
<body>
<center>
<table border="1" width="700">
<tr>
<td width="100%" colspan="2" align="center">删除学生信息程序</td>
</tr>
<tr>
<td width="100%" colspan="2">删除信息成功!</td>
</tr>
</table>
</center>
<a href="delete1.jsp">返回学生信息</a>
</body>
</html> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询