使用execSQL语句

时间:2015-04-22 21:11:04

标签: android android-sqlite

我正在尝试更新数据库表中的行,但由于下面提到的一些问题而没有更新。请帮忙 ! 这是logcat错误。

04-23 02:34:56.435:D / PackageItemInfo(27696):loadIcon(cached)name = org.example.beproj.MainActivity 04-23 02:35:06.576:D / dalvikvm(27696):GC_FOR_ALLOC释放418K,40%免费10126K / 16688K,暂停18ms,总计26ms 04-23 02:35:06.596:I / dalvikvm-heap(27696):将堆(frag case)增长到19.996MB,用于8294416字节分配 04-23 02:35:06.616:D / dalvikvm(27696):GC_CONCURRENT释放23K,27%自由18202K / 24792K,暂停6ms + 2ms,总计22ms 04-23 02:35:16.797:E / SQLiteLog(27696):( 1)没有这样的列:ID 04-23 02:35:16.797:D / AndroidRuntime(27696):关闭虚拟机 04-23 02:35:16.797:W / dalvikvm(27696):threadid = 1:线程退出未捕获异常(组= 0x41276ae0) 04-23 02:35:16.797:E / AndroidRuntime(27696):致命异常:主要 04-23 02:35:16.797:E / AndroidRuntime(27696):android.database.sqlite.SQLiteException:没有这样的列:ID(代码1):,编译时:UPDATE vgs SET Steps ='xguvdyij'WHERE ID = 0 04-23 02:35:16.797:E / AndroidRuntime(27696):在android.database.sqlite.SQLiteConnection.nativePrepareStatement(本机方法) 04-23 02:35:16.797:E / AndroidRuntime(27696):在android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:888) 04-23 02:35:16.797:E / AndroidRuntime(27696):在android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:499) 04-23 02:35:16.797:E / AndroidRuntime(27696):在android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) 04-23 02:35:16.797:E / AndroidRuntime(27696):在android.database.sqlite.SQLiteProgram。(SQLiteProgram.java:58) 04-23 02:35:16.797:E / AndroidRuntime(27696):在android.database.sqlite.SQLiteStatement。(SQLiteStatement.java:31) 04-23 02:35:16.797:E / AndroidRuntime(27696):在android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1663) 04-23 02:35:16.797:E / AndroidRuntime(27696):在android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1594) 04-23 02:35:16.797:E / AndroidRuntime(27696):at org.example.beproj.update_final $ 2.onClick(update_final.java:92) 04-23 02:35:16.797:E / AndroidRuntime(27696):在android.view.View.performClick(View.java:4278) 04-23 02:35:16.797:E / AndroidRuntime(27696):在android.view.View $ PerformClick.run(View.java:17429) 04-23 02:35:16.797:E / AndroidRuntime(27696):在android.os.Handler.handleCallback(Handler.java:725) 04-23 02:35:16.797:E / AndroidRuntime(27696):在android.os.Handler.dispatchMessage(Handler.java:92) 04-23 02:35:16.797:E / AndroidRuntime(27696):在android.os.Looper.loop(Looper.java:137) 04-23 02:35:16.797:E / AndroidRuntime(27696):在android.app.ActivityThread.main(ActivityThread.java:5099) 04-23 02:35:16.797:E / AndroidRuntime(27696):at java.lang.reflect.Method.invokeNative(Native Method) 04-23 02:35:16.797:E / AndroidRuntime(27696):at java.lang.reflect.Method.invoke(Method.java:511) 04-23 02:35:16.797:E / AndroidRuntime(27696):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:803) 04-23 02:35:16.797:E / AndroidRuntime(27696):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:570) 04-23 02:35:16.797:E / AndroidRuntime(27696):at dalvik.system.NativeStart.main(Native Method)

代码是

db=SQLiteDatabase.openDatabase(DB_path, null,SQLiteDatabase.OPEN_READWRITE);
new_text=editText1.getText().toString();
String update = "UPDATE "+table_name+" SET Steps = '"+ new_text +"' WHERE ID = " + position;
db.execSQL(update); 

1 个答案:

答案 0 :(得分:1)

错误指定了问题:

FATAL EXCEPTION: main 04-23 02:35:16.797: E/AndroidRuntime(27696): android.database.sqlite.SQLiteException: no such column: ID (code 1): , while compiling: UPDATE vgs SET Steps = 'xguvdyij' WHERE ID = 0