android - Sqlite Database Query returns null -
i have database , mthod values every table.
however, want table rows route = 5 (for example)
this query:
cursor cursor = db.query(table_name_routes, new string[] {"id","route","busstop","longitude","latitude"}, "route" + "=" + busroute , null, null, null, null);
i've tried tons of different versions of clause, none seem work, list returned size 0, when should size 20.
edit:
changed line to:
cursor cursor = db.query(table_name_routes, new string[] {"id","route","busstop","longitude","latitude"}, "route" + "=`"+ busroute+"`" , null, null, null, null);
log logcat
05-02 18:14:23.396: e/sqlitelog(15408): (1) no such column: 5 05-02 18:14:23.396: d/androidruntime(15408): shutting down vm 05-02 18:14:23.396: w/dalvikvm(15408): threadid=1: thread exiting uncaught exception (group=0x40cee300) 05-02 18:14:23.400: e/androidruntime(15408): fatal exception: main 05-02 18:14:23.400: e/androidruntime(15408): java.lang.runtimeexception: unable start activity componentinfo{com.mso.master/com.mso.master.mainactivity}: android.database.sqlite.sqliteexception: no such column: 5 (code 1): , while compiling: select id, route, busstop, longitude, latitude routes route=`5` 05-02 18:14:23.400: e/androidruntime(15408): @ android.app.activitythread.performlaunchactivity(activitythread.java:2185) 05-02 18:14:23.400: e/androidruntime(15408): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2210) 05-02 18:14:23.400: e/androidruntime(15408): @ android.app.activitythread.access$600(activitythread.java:142) 05-02 18:14:23.400: e/androidruntime(15408): @ android.app.activitythread$h.handlemessage(activitythread.java:1208) 05-02 18:14:23.400: e/androidruntime(15408): @ android.os.handler.dispatchmessage(handler.java:99) 05-02 18:14:23.400: e/androidruntime(15408): @ android.os.looper.loop(looper.java:137) 05-02 18:14:23.400: e/androidruntime(15408): @ android.app.activitythread.main(activitythread.java:4931) 05-02 18:14:23.400: e/androidruntime(15408): @ java.lang.reflect.method.invokenative(native method) 05-02 18:14:23.400: e/androidruntime(15408): @ java.lang.reflect.method.invoke(method.java:511) 05-02 18:14:23.400: e/androidruntime(15408): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:791) 05-02 18:14:23.400: e/androidruntime(15408): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:558) 05-02 18:14:23.400: e/androidruntime(15408): @ dalvik.system.nativestart.main(native method) 05-02 18:14:23.400: e/androidruntime(15408): caused by: android.database.sqlite.sqliteexception: no such column: 5 (code 1): , while compiling: select id, route, busstop, longitude, latitude routes route=`5` 05-02 18:14:23.400: e/androidruntime(15408): @ android.database.sqlite.sqliteconnection.nativepreparestatement(native method) 05-02 18:14:23.400: e/androidruntime(15408): @ android.database.sqlite.sqliteconnection.acquirepreparedstatement(sqliteconnection.java:882) 05-02 18:14:23.400: e/androidruntime(15408): @ android.database.sqlite.sqliteconnection.prepare(sqliteconnection.java:493) 05-02 18:14:23.400: e/androidruntime(15408): @ android.database.sqlite.sqlitesession.prepare(sqlitesession.java:588) 05-02 18:14:23.400: e/androidruntime(15408): @ android.database.sqlite.sqliteprogram.<init>(sqliteprogram.java:58) 05-02 18:14:23.400: e/androidruntime(15408): @ android.database.sqlite.sqlitequery.<init>(sqlitequery.java:37) 05-02 18:14:23.400: e/androidruntime(15408): @ android.database.sqlite.sqlitedirectcursordriver.query(sqlitedirectcursordriver.java:44) 05-02 18:14:23.400: e/androidruntime(15408): @ android.database.sqlite.sqlitedatabase.rawquerywithfactory(sqlitedatabase.java:1314) 05-02 18:14:23.400: e/androidruntime(15408): @ android.database.sqlite.sqlitedatabase.querywithfactory(sqlitedatabase.java:1161) 05-02 18:14:23.400: e/androidruntime(15408): @ android.database.sqlite.sqlitedatabase.query(sqlitedatabase.java:1032) 05-02 18:14:23.400: e/androidruntime(15408): @ android.database.sqlite.sqlitedatabase.query(sqlitedatabase.java:1200) 05-02 18:14:23.400: e/androidruntime(15408): @ com.mso.master.datamanipulator.selectroute(datamanipulator.java:167) 05-02 18:14:23.400: e/androidruntime(15408): @ com.mso.master.dbaccess.getbusroute(dbaccess.java:43) 05-02 18:14:23.400: e/androidruntime(15408): @ com.mso.master.mainactivity.oncreate(mainactivity.java:130) 05-02 18:14:23.400: e/androidruntime(15408): @ android.app.activity.performcreate(activity.java:5008) 05-02 18:14:23.400: e/androidruntime(15408): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1079) 05-02 18:14:23.400: e/androidruntime(15408): @ android.app.activitythread.performlaunchactivity(activitythread.java:2139) 05-02 18:14:23.400: e/androidruntime(15408): ... 11 more
route
type text
, should there in single quotes
, try this
cursor cursor = db.query(table_name_routes, new string[] {"id","route","busstop","longitude","latitude"}, "route" + "='"+ busroute+"'" , null, null, null, null);
Comments
Post a Comment