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

急求SQL语句!!!大侠救命!!
<%@   page   contentType= "text/html;   charset=gb2312 "   language= "java "   import= "java.sql.* "   errorPage= " "   %>
<%request.setCharacterEncoding( "gb2312 ")   ;%>
<jsp:useBean   id= "stmt "   scope= "page "   class= "beans.connDB "/>
<jsp:useBean   id= "chStr "   scope= "page "   class= "beans.chStr "/>
<body>
<%
int   passageid=0;
if(request.getParameter( "passageid ")==null){
response.sendRedirect( "passage_manage.jsp ");
}else{
passageid=Integer.parseInt(request.getParameter( "passageid "));
if(passageid!=0){
String   sql= " ";
sql= "update   tb_passage   set   check= '已审核 '   where   ID= "+passage;
int   ret=0;
ret=stmt.executeUpdate(sql);
if   (ret!=0){
out.println( " <script   language= 'javascript '> alert( '审核成功! ');window.location.href= 'passage_manage.jsp '; </script> ");
}else{
out.println( " <script   language= 'javascript '> alert( '审核失败! ');window.location.href= 'passage_manage.jsp '; </script> ");
}
}
}
%>
</body>
</html>

passageid已经传过来了,但是执行总是审核失败,请问我的SQL语句哪里错了。

------解决方案--------------------
友情UP!
------解决方案--------------------
sql= "update tb_passage set check= '已审核 ' where ID= "+passage;
__________
sql= "update tb_passage set check= '已审核 ' where ID= '+passageid ' ";
试试看一下
------解决方案--------------------
sql= "update tb_passage set check= '已审核 ' where ID= "+passageid;

------解决方案--------------------
executeUpdate方法可以返回nothing,自己看api

------解决方案--------------------
在这里你定义的是int passageid=0;
if(request.getParameter( "passageid ")==null){
response.sendRedirect( "passage_manage.jsp ");
而在这里sql= "update tb_passage set check= '已审核 ' where ID= "+passage;
你的ID却为passage,会找不到字段,但是不提示错误

------解决方案--------------------
passageid=Integer.parseInt(request.getParameter( "passageid "));
打印出来passageid的值我感觉这里可能没有转换过来