0

它给出了我的错误。如何获得所有字段。谢谢

show.setOnClickListener(new Button.OnClickListener() {
     public void onClick(View arg0) 
     {
            String mm = seg.getText().toString();
            String mmm =ubs.getText().toString();
            String mmmm=area.getText().toString();
            String mmmmm= microarea.getText().toString();
            String mmmmmm= imovel.getText().toString();
                              String query = ( " SELECT * FROM DOMICIL WHERE "
              + " SEG ="+ mm
              + " And UNIDADE ="+mmm
              + " And  AREA ="+mmmm 
              + " And MICROAREA ="+mmmmm
              + " And IMOVEL ="+ mmmmmm );
            Cursor c =my.rawQuery(query,null);
            c.moveToFirst();
            while(!c.isAfterLast())
            {
              int id = c.getInt(0);
              seg.setText(c.getString(1));
              ubs.setText(c.getString(2));
              area.setText(c.getString(3));
              microarea.setText(c.getString(4));
              imovel.setText(c.getString(5));
              numer_casa.setText(c.getString(6));
              cep.setText(c.getString(7));
              complemento.setText(c.getString(8));
              c.moveToNext();
            } 
           c.close();  
           }  
        });
     }
4

3 回答 3

0

假设您的列是文本,请尝试将要查询的文本括在引号中。

前任。

+ " SEG = '"+ mm + "'"
+ " And UNIDADE = '"+mmm  + "'"
+ " And  AREA = '"+mmmm  + "'"
+ " And MICROAREA = '"+mmmmm + "'"
+ " And IMOVEL = '"+ mmmmmm  + "'" );
于 2012-06-20T19:18:49.567 回答
0

如果为 null ,则用于 Strings ; SEG LIKE %'"+mm"'%

于 2012-06-20T19:59:34.740 回答
0

如果我是你,我可能会做类似的事情

String query = " SELECT * FROM DOMICIL WHERE "
              + " SEG = ? " 
              + " And UNIDADE = ?" 
              + " And  AREA = ? " 
              + " And MICROAREA = ? " 
              + " And IMOVEL = ? ";
Cursor c =my.rawQuery(query,new String[]{mm,mmm,mmmm,mmmmm,mmmmmm});

我还会使用更具描述性的变量名称。

于 2012-06-20T20:03:31.503 回答