2011-10-20 14 views
0

データベースからデータを取得できませんでした。以下の私のSQLクエリとLogcatエラー AndroidのSQLクエリデータベースのデータを取得しようとしていません

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

は、スタックオーバーフローへようこそ。特定の応答が役立つ場合は、それをupvoteしてください。あなたの回答があなたの質問に適切に答えたら、それを受け入れてください。 –

+0

[Android Database Cursor Null Valuesを渡す]の重複可能性があります(http://stackoverflow.com/questions/7880751/android-database-cursor-passing-null-values) –

答えて

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 
+0

SELECT ... SELECT ...一つのステートメントとして?それはSQLite上で動作しますか? IMHOこれは2つの別々の声明です。 –

関連する問題