2011-05-09 94 views
0
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=+ 
+0

「WHERE sign = +」和「do」錯誤.. – Mikaveli 2011-05-09 10:20:10

+0

我該怎麼解決它? – user65544 2011-05-09 10:21:28

+1

作爲第一通KEY_SIGN + 「= '」 +符號+ 「'」, – Mikaveli 2011-05-09 10:23:30

回答

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); 
}