public Cursor getSen_List(long id_thsen) {
String strTmp = "select "
+SENS_TABLE+"."+KEY_SEN_ID+","
+SENS_TABLE+"."+KEY_SEN_ID_TH_SEN+","
+SENS_TABLE+"."+KEY_SEN_ID_LANG+","
+SENS_TABLE+"."+KEY_SEN+","
+SENS_TABLE+"."+KEY_SEN_READING+","
+" from "+SENS_TABLE+ ","
+" where "+SENS_TABLE+"."+KEY_SEN_ID_TH_SEN + "=" +id_thsen+","
+null+"," +null+"," +null+"," +null;
return db.rawQuery(strTmp,null);}
這個查詢數據,我得到例句列表 但如果我想改變的方式來寫這樣的而不是如何從SQLite的
public Cursor getSen_List(long id_thsen) {
String strTmp = "select "
+SENS_TABLE+"."+KEY_SEN_ID+","
+SENS_TABLE+"."+KEY_SEN_ID_TH_SEN+","
+SENS_TABLE+"."+KEY_SEN_ID_LANG+","
+SENS_TABLE+"."+KEY_SEN+","
+SENS_TABLE+"."+KEY_SEN_READING+","
+" from "+SENS_TABLE+","
+" where "+SENS_TABLE+"."+KEY_SEN_ID_TH_SEN + id_thsen+","
+null+"," +null+"," +null+"," +null+",";
return db.rawQuery(strTmp,null);}
的方式有什麼不對?因爲它不工作
請幫助........
,這是我的logcat ........
02-10 20:48:18.050: ERROR/AndroidRuntime(818): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.proj/com.android.proj.Sens_Show}: android.database.sqlite.SQLiteException: near "from": syntax error: , while compiling: select Sentences._id,Sentences.id_thsen,Sentences.id_lang,Sentences.sen,Sentences.reading, from Sentences, where Sentences.id_thsen1,null,null,null,null, 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at android.os.Handler.dispatchMessage(Handler.java:99) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at android.os.Looper.loop(Looper.java:123) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at android.app.ActivityThread.main(ActivityThread.java:4627) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at java.lang.reflect.Method.invokeNative(Native Method) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at java.lang.reflect.Method.invoke(Method.java:521) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at dalvik.system.NativeStart.main(Native Method) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): Caused by: android.database.sqlite.SQLiteException: near "from": syntax error: , while compiling: select Sentences._id,Sentences.id_thsen,Sentences.id_lang,Sentences.sen,Sentences.reading, from Sentences, where Sentences.id_thsen1,null,null,null,null, 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at android.database.sqlite.SQLiteCompiledSql.(SQLiteCompiledSql.java:64) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:80) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at android.database.sqlite.SQLiteQuery.(SQLiteQuery.java:46) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1315) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at com.android.proj.DBAdapter.getSen_List(DBAdapter.java:875) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at com.android.proj.Sens_Show.listData(Sens_Show.java:91) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at com.android.proj.Sens_Show.onCreate(Sens_Show.java:63) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 02-10 20:48:18.050: ERROR/AndroidRuntime(818): ... 11 more
那麼,我需要的是一個誰幫助我= =謝謝 – 2011-02-10 14:51:05
與那種態度,你不會得到太多...... – techiServices 2011-02-10 15:13:42
那麼,檢查什麼混亂產生 - 然後嘗試通過sqlite CLI(命令行界面,PC上的SQLite很好)來運行它。發現問題。 – 2011-02-10 15:52:32