当前位置:   article > 正文

android使用sql语句,使用execSQL语句在android中更新表中的行

android execsql

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

2月4日至23日:34:56.435:d/PackageItemInfo(27696):loadIcon(缓存)名称= org.example.beproj.MainActivity 2月4日至23日: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):为8294416字节的分配增加堆(碎片)至19.996MB 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)no such column:ID 04-23 02:35:16.797:D/AndroidRuntime(27696):关闭VM 04-23 02:35:16.797:W/dalvikvm(27696):threadid = 1:线程以未捕获的异常退出(group = 0x41276ae0) 04-23 02:35:16.797:E/AndroidRuntime(27696):致命例外:主 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 04-23 02:35:16.797:E/AndroidRuntime(27696):at android.database.sqlite.SQLiteConnection.nativePrepareStatement Native Method) 04-23 02:35:16.797:E/AndroidRuntime(27696):at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:888) 04-23 02:35:16.797:E/AndroidRuntime (27696):at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:499) 04-23 02:35:16.797:E/AndroidRuntime(27696):at android.database.sqlite.SQLiteSession.prepare(SQLiteSession .java:588) 04-23 02:35:16.797:E/AndroidRuntime(2 (SQLiteStatement.java:7696):at android.database.sqlite.SQLiteProgram。(SQLiteProgram.java:58) 04-23 02:35:16.797:E/AndroidRuntime(27696):at android.database.sqlite.SQLiteStatement。(SQLiteStatement.java: 31) 04-23 02:35:16.797:E/AndroidRuntime(27696):at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1663) 04-23 02:35:16.797:E/AndroidRuntime 27696):at 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):at android.view.View.performClick(View.java:4278) 04-23 02:35:16.797:E/AndroidRuntime (27696):at android.view.View $ PerformClick.run(View.java:17429) 04-23 02:35:16.797:E/AndroidRuntime(2在android.os.Handler.handleCallback(Handler.java:725) 04-23 02:35:16.797:E/AndroidRuntime(27696):at android.os.Handler.dispatchMessage(Handler.java:92) 04-23 02:35:16.797:E/AndroidRuntime(27696):at android.os.Looper.loop(Looper.java:137) 04-23 02:35:16.797:E/AndroidRuntime(27696):at 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):在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(Zygote Init.java:570) 04-23 02:35:16.797:E/AndroidRuntime(27696):at dalvik.system.NativeStart。主(本地方法)

而且代码

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);

+0

我也用这个代码,但它不会得到更新 –

+0

ContentValues newValues =新ContentValues( ); newValues.put(“Steps”,new_text); String where =“_ id =”+ position; db_update(table_name,newValues,“_ id =”+ position,null); –

+0

'没有这样的列:ID'检查您的数据库与编辑器,如果它包含必要的列。 –

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/267249
推荐阅读
相关标签
  

闽ICP备14008679号