dimanche 6 septembre 2015

how to solve syntax exception in sqlite while using cursor query?

In my project, I use this cursor query: Cursor c = db.query(VivzHelper.TX_TABLE, columns, helper.TX_ID + "='" + name + "' AND " + helper.TX_DATE + " BETWEEN '"+ datefrom.from_date + "' AND '" + dateto.to_date + "' AND '"+ helper.TX_TYPE +" = '"+"DM", null, helper.TX_NAME, null, null);

I get the following exception for my above query:

android.database.sqlite.SQLiteException: near "DM": syntax error (code 1): , while compiling: SELECT _id, txname, SUM(amount) AS amount, date, txtype FROM transactions WHERE txid='E' AND date BETWEEN '2015-09-06' AND '2015-09-06' AND 'txtype = 'DM GROUP BY txname

Aucun commentaire:

Enregistrer un commentaire