我错了什么?

时间:2011-05-09 10:17:55

标签: android sql sqlite

public Cursor getChart(String sign ) {
    return db.query(CHART_TABLE, new String[] { 
            KEY_CHART_ID,
            KEY_SIGN,
            KEY_TOTAL },
            KEY_SIGN + "=" + sign, 
            null, null, null, null, null);
}

05-09 17:14:39.260: ERROR/AndroidRuntime(14935): android.database.sqlite.SQLiteException: near "+": syntax error: , while compiling: SELECT _id, sign, total FROM ChartTable WHERE sign=+

1 个答案:

答案 0 :(得分:3)

查询数据库的错误方法。试试这个..

public Cursor getChart(String sign ) {
    return db.query(CHART_TABLE, new String[] { 
            KEY_CHART_ID,
            KEY_SIGN,
            KEY_TOTAL },
            "KEY_SIGN =?", new String[]{sign}, 
            null, null, null);
}