-2

我有这段代码不起作用。谁能告诉我我做错了什么?

    String option = names.getText().toString();

    Cursor c = db.rawQuery("SELECT * from numbers Where fname=option", null);
4

3 回答 3

1

更改如下:

 Cursor c = db.rawQuery("SELECT * from numbers Where fname='"+option+"' ", null);
于 2013-08-23T03:51:44.183 回答
1

尝试这个

String query = "SELECT * from numbers Where fname='"+ option +"'";      
    database.execSQL(query);
于 2013-08-23T03:53:34.103 回答
1

更喜欢使用带有?占位符的 Prepared Statement。

String option = names.getText().toString();
String query = "SELECT * from numbers Where fname = ?"

Cursor c = db.rawQuery(query, new String[] {option});
于 2013-08-23T03:55:01.907 回答