日期:2014-05-20  浏览次数:20695 次

急用--帮帮忙
sql= "select   *   from   dzxx_b ";
                if((this.r1.getText().trim())!=null){
                if((this.r2.getText().trim())!=null){
                sql+= "where   dzbh= ' "+this.r1.getText()+ " '   and   dzxm= ' "+this.r2.getText()+ " ' ";
                }
                else
                sql= "where   dzbh= ' "+this.r1.getText()+ " ' ";
               
                }
                else
                {
                if((this.r2.getText().trim())!=null){
               
                sql+= "where   dzxm= ' "+this.r2.getText()+ " ' ";
                }
               
                }  
我是想在2个文本中任意输入条件,实现查询;
请大家帮帮忙,为什么老师输入第一个   条件点查询出现select   *   from   dzxx_b   where   dzbh= '输入内容 '   and   dzxm= ' ',为什么后面那条件也出来了;    



------解决方案--------------------
检查你的判断条件撒。。。。。。。
------解决方案--------------------
this.r2.getText().trim()是不等于空,它等于 " "
--------------------------------------------
看看这个问题,或许对你有帮助:)


为什么在JSP中将传进来的参数要判断是不是为空null还要判断是不是为 " "呢,为什么啊双重判断呢
http://community.csdn.net/Expert/topic/5285/5285513.xml?temp=.3930475


祝:进步。
------解决方案--------------------
System.out.println(sql);
把SQL输出,然后放到数据库里去跑一下,为社么不对~不就一目了然了.