日期:2014-05-18  浏览次数:20813 次

我在做删除功能时,数据库记录已删除,但是页面要报错!
<%@   page   contentType= "text/html;   charset=GBK "   %>
<%@   page   import= "java.sql.* "%>
<html>
<head>

<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 ">
<title> 删除管理员 </title>
</head>

<body>
  <%
  String   adminid=request.getParameter( "adminid ");
int   adminid1=   Integer.parseInt(adminid.trim());
//if(rsid1.equals( "null "))
//{}
//else
//{
%>
<%

String     sDBDriver= "com.microsoft.jdbc.sqlserver.SQLServerDriver ";
Class.forName(sDBDriver);
String   sConnStr= "jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=Store ";
String   pusername= "sa ";
String   pwd1= " ";
Connection   connWeb=DriverManager.getConnection(sConnStr,pusername,pwd1);
Statement   stmt=connWeb.createStatement();  
ResultSet   rs=stmt.executeQuery( "delete   from   goodsadmin   where   adminid= ' "+adminid1+ " ' ");
  out.print( " <SCRIPT   language=JavaScript> alert( '删除成功! ');this.location.href= 'manager_list.jsp '; </SCRIPT> ");
rs.close();
//}
%>  
</body>
</html>

源代码如上:

------解决方案--------------------
删除是 executeUpdate 不是 executeQuery
------解决方案--------------------
顶楼上的
------解决方案--------------------
同意! executeQuery好像是用来做查询用的!