你的 变量定义在 if 域里,我疑惑!大侠们请问,那些变量出了 if 域是不是就没有了?

解决方案 »

  1.   

    int total=0,selecta....=0;
    if(rs.next())
    {
    total=rs.getInt("selecta")+rs.getInt("selectb")+rs.getInt("selectc")+rs.getInt("selectd")+rs.getInt("selecte")+rs.getInt("selectf");selecta=(rs.getInt("selecta")/total)*100;
    selectb=(rs.getInt("selectb")/total)*100;
    selectc=(rs.getInt("selectc")/total)*100;
    selectd=(rs.getInt("selectd")/total)*100;
    selecte=(rs.getInt("selecte")/total)*100;
    selectf=(rs.getInt("selectf")/total)*100;}else{out.println("<script>alert('还没有人投票!');history.go(-1);</script>");

      

  2.   

    感谢楼上的现在就只有selecta=(rs.getInt("selecta")/total)*100;这里有错了其它的都正确了
    但是只要selecta=(rs.getInt("selecta")/total)*100;就要报错
    错误是
    Exception Report:
    javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index