我甚至无法从数据库中检索数据 - 虽然我改变了一些变化,但是我得到了建议,然后我的查询也无法正常工作。下面是我的Sql Query和Log-cat错误
SQL查询: -
Cursor cur3 = db3.rawQuery("SELECT "+pretestTable+"."+columnID+","+
" "+pretestTable+"."+DDL_Testing_Session+","+
" "+pretestTable+"."+Text_Reason+","+
" "+pretestTable+"."+Text_Howmany+","+
" "+pretestTable+"."+Text_Ques1+","+
" "+pretestTable+"."+RBL_Ques2a+","+
" "+pretestTable+"."+RBL_Ques2b+","+
" "+pretestTable+"."+RBL_Ques3+","+
" "+pretestTable+"."+TXT_Ques4+","+
" "+pretestTable+"."+RBL_Ques5+","+
" "+pretestTable+"."+RBL_Ques6+","+
" "+pretestTable+"."+RBL_Ques7+","+
" "+pretestTable+"."+RBL_Ques8+","+
" "+pretestTable+"."+RBL_Ques9+","+
" "+pretestTable+"."+DDL_Sick+","+
" "+pretestTable+"."+TXT_Ques11+","+
" "+pretestTable+"."+RBL_Ques12+","+
" "+pretestTable+"."+TXT_Ques13+","+
" "+pretestTable+"."+TXT_Ques14+","+
" "+pretestTable+"."+RBL_Ques15+","+
" "+pretestTable+"."+RBL_Ques16+","+
" "+pretestTable+"."+RBL_Ques17+","+
" "+pretestTable+"."+TXT_Ques18+","+
" "+pretestTable+"."+TXT_Vct+" FROM "+pretestTable+"SELECT "+fingerTable+"."+Template11+"FROM"+fingerTable+" WHERE " + pretestTable+"."+columnID+" = "+fingerTable+"."+Template11+" AND "+pretestTable+"."+"pretest_id=?" , null);
Logcat错误:---
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): FATAL EXCEPTION: main
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.a1technology.remoteid/com.a1technology.remoteid.Screening}: android.database.sqlite.SQLiteException: near ".": syntax error: , while compiling: SELECT tbl_pre_test.ID, tbl_pre_test.ddlTestingSession, tbl_pre_test.txtReason, tbl_pre_test.txthowmany, tbl_pre_test.txtques1, tbl_pre_test.rblques2a, tbl_pre_test.rblques2b, tbl_pre_test.rblques3, tbl_pre_test.txtques4, tbl_pre_test.rblques5, tbl_pre_test.rblques6, tbl_pre_test.rblques7, tbl_pre_test.rblques8, tbl_pre_test.rblques9, tbl_pre_test.ddlsick, tbl_pre_test.txtques11, tbl_pre_test.rblques12, tbl_pre_test.txtques13, tbl_pre_test.txtques14, tbl_pre_test.rblques15, tbl_pre_test.rblques16, tbl_pre_test.rblques17, tbl_pre_test.txtques18, tbl_pre_test.txtVCT FROM tbl_pre_testSELECT tbl_finger.templateFROMtbl_finger WHERE tbl_pre_test.ID = tbl_finger.template AND tbl_pre_test.pretest_id=?
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at android.os.Handler.dispatchMessage(Handler.java:99)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at android.os.Looper.loop(Looper.java:123)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at android.app.ActivityThread.main(ActivityThread.java:3647)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at java.lang.reflect.Method.invokeNative(Native Method)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at java.lang.reflect.Method.invoke(Method.java:507)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at dalvik.system.NativeStart.main(Native Method)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): Caused by: android.database.sqlite.SQLiteException: near ".": syntax error: , while compiling: SELECT tbl_pre_test.ID, tbl_pre_test.ddlTestingSession, tbl_pre_test.txtReason, tbl_pre_test.txthowmany, tbl_pre_test.txtques1, tbl_pre_test.rblques2a, tbl_pre_test.rblques2b, tbl_pre_test.rblques3, tbl_pre_test.txtques4, tbl_pre_test.rblques5, tbl_pre_test.rblques6, tbl_pre_test.rblques7, tbl_pre_test.rblques8, tbl_pre_test.rblques9, tbl_pre_test.ddlsick, tbl_pre_test.txtques11, tbl_pre_test.rblques12, tbl_pre_test.txtques13, tbl_pre_test.txtques14, tbl_pre_test.rblques15, tbl_pre_test.rblques16, tbl_pre_test.rblques17, tbl_pre_test.txtques18, tbl_pre_test.txtVCT FROM tbl_pre_testSELECT tbl_finger.templateFROMtbl_finger WHERE tbl_pre_test.ID = tbl_finger.template AND tbl_pre_test.pretest_id=?
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1356)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1324)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at com.a1technology.remoteid.Screening.onCreate(Screening.java:320)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)
10-20 23:07:34.771: ERROR/AndroidRuntime(1296): ... 11 more
答案 0 :(得分:0)
你的SQL查询缺少空格。这样:
FROM tbl_pre_testSELECT tbl_finger.templateFROMtbl_finger WHERE tbl_pre_test.ID
需要这样:
FROM tbl_pre_test SELECT tbl_finger.template FROM tbl_finger WHERE tbl_pre_test.ID