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

提问:ResultSet在if语句中不可操作?
<%
        String   idno=request.getParameter( "searchidno ");     //获取提交的身份证号
        String   name=request.getParameter( "searchname ");       //获取提交的姓名
        String   origin=request.getParameter( "searchorigin ");   //获取提交的籍贯
        if(idno==null){idno= " ";}
        byte   b[]=idno.getBytes( "ISO-8859-1 ");
        idno=new   String(b);        
        if(name==null){name= " ";}
        byte   c[]=name.getBytes( "ISO-8859-1 ");
        name=new   String(c);
        if(origin==null){origin= " ";}
        byte   d[]=origin.getBytes( "ISO-8859-1 ");
        origin=new   String(d);
       
       
       
        String   sql1= "select   *   from   basic   where   idno= ' "+idno+ " ' ";
        String   sql2= "select   *   from   basic   where   name= '% "+name+ "% ' ";
        String   sql3= "select   *   from   basic   where   origin= ' "+origin+ " ' ";
        String   sql4= "select   *   from   basic   where   idno= ' "+idno+ " '   and   name= '% "+name+ "% ' ";
        String   sql5= "select   *   from   basic   where   idno= ' "+idno+ " '   and   origin= ' "+origin+ " ' ";
        String   sql6= "select   *   from   basic   where   name= '% "+name+ "% '   and   origin= ' "+origin+ " ' ";
        String   sql7= "select   *   from   basic   where   idno= ' "+idno+ " '   and   name= '% "+name+ "% '   and   origin= ' "+origin+ " ' ";
      CONTROLDB   con=new   CONTROLDB();
      ResultSet   rs;
      if(idno== " "   &   name== " "   &   origin== " "){response.sendRedirect( "basicsearcherror.jsp ");}
      else   if(idno== " "   &   name== " "   &   origin!= " "){ResultSet   rs=con.executeQuery(sql3);}
      else   if(idno== " "   &   name!= " "   &   origin== " "){ResultSet   rs=con.executeQuery(sql2);}
      else   if(idno!= " "   &   name== " "   &   origin== " "){ResultSet   rs=con.executeQuery(sql1);}
      else   if(idno!= " "   &   name!= " "   &   origin== " "){ResultSet   rs=con.executeQuery(sql4);}
      else   if(idno!= " " &n