2012-07-20 133 views
0

我在數據庫中使用以下命令更新表:更新android系統

public long UpdateIncomeDB(String item,String price,String update) throws SQLException 
{ 
    ContentValues initialValues = new ContentValues(); 
    initialValues.put(KEY_DESC, item); 
    initialValues.put(KEY_INCOME, price); 
    initialValues.put(KEY_TOTAL, price); 
    db.update(DATABASE_TABLE, initialValues, "description" + "=" +update, null); 
    return 0; 
} 

但正顯示出錯誤的特定列不exists..But我檢查其具有柱entry..Please數據庫幫助我..

MY logcat的是:

07-20 11:25:03.157: E/Database(1090): Error updating total=45.00 price=45.00 description=ghhy using UPDATE incomexpense SET total=?, price=?, description=? WHERE description=ghhy 
07-20 11:25:03.167: D/AndroidRuntime(1090): Shutting down VM 
07-20 11:25:03.167: W/dalvikvm(1090): threadid=3: thread exiting with uncaught exception (group=0x4001b188) 
07-20 11:25:03.167: E/AndroidRuntime(1090): Uncaught handler: thread main exiting due to uncaught exception 
07-20 11:25:03.617: D/dalvikvm(1090): GC freed 7418 objects/376640 bytes in 421ms 
07-20 11:25:03.617: E/AndroidRuntime(1090): android.database.sqlite.SQLiteException: no such column: ghhy: , while compiling: UPDATE incomexpense SET total=?, price=?, description=? WHERE description=ghhy 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at android.database.sqlite.SQLiteProgram.native_compile(Native Method) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at android.database.sqlite.SQLiteProgram.compile(SQLiteProgram.java:110) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:41) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1027) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1556) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1500) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at com.budget1.DBadapter.UpdateIncomeDB(DBadapter.java:575) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at com.budget1.IncomeDetailsEdit$2.onClick(IncomeDetailsEdit.java:46) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at android.view.View.performClick(View.java:2364) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at android.view.View.onTouchEvent(View.java:4179) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at android.widget.TextView.onTouchEvent(TextView.java:6541) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at android.view.View.dispatchTouchEvent(View.java:3709) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at android.app.Activity.dispatchTouchEvent(Activity.java:2061) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1691) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at android.os.Handler.dispatchMessage(Handler.java:99) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at android.os.Looper.loop(Looper.java:123) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at android.app.ActivityThread.main(ActivityThread.java:4363) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at java.lang.reflect.Method.invokeNative(Native Method) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at java.lang.reflect.Method.invoke(Method.java:521) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
07-20 11:25:03.617: E/AndroidRuntime(1090):  at dalvik.system.NativeStart.main(Native Method) 
+0

沒有這樣的列:ghhy: – 2012-07-20 05:58:33

回答

0

認沽更新值四捨五入引號內

"description" + "=" +update 

把雙引號

"description" + "=" +"'"+update+"'" 
+0

由於其工作... .... – 2012-07-20 06:15:55

0

使用本WHERE子句: 「描述= '」 +升級+ 「'」

在SQL查詢中的所有字符串值應通過「