I wrote an application to update rows in SQlite Db, below is the code for update in data handler:
public long updatedata(String ID, String NAME,String NUMBER)
{
ContentValues content = new ContentValues();
content.put(name, NAME);
content.put(number,NUMBER);
return db.update(table_name, content, "id "+"="+ID, null);
}
now when i need to update a row i used below code:
Datahandler data =new Datahandler();
data.open();
long updateresult = data.updatedata(oldID, cloudnames.get(pos), cloudnumbers.get(pos));
data.close();
Also assume that the above provided value is exist and valid and also i am sure that there is an id = jo_2 in my database, the problem is when i run the code an exception appear as below:
02-19 23:59:34.200: E/SQLiteLog(18485): (1) no such column: jo_2
02-19 23:59:34.205: W/dalvikvm(18485): threadid=11: thread exiting with uncaught exception (group=0x41b30c08)
02-19 23:59:34.210: E/AndroidRuntime(18485): FATAL EXCEPTION: IntentService[test-service]
02-19 23:59:34.210: E/AndroidRuntime(18485): Process: com.kaizendroid.bc, PID: 18485
02-19 23:59:34.210: E/AndroidRuntime(18485): android.database.sqlite.SQLiteException: no such column: jo_2 (code 1): , while compiling: UPDATE info SET name=?,number=? WHERE id =jo_2
02-19 23:59:34.210: E/AndroidRuntime(18485): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
02-19 23:59:34.210: E/AndroidRuntime(18485): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1113)
02-19 23:59:34.210: E/AndroidRuntime(18485): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:690)
02-19 23:59:34.210: E/AndroidRuntime(18485): at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
02-19 23:59:34.210: E/AndroidRuntime(18485): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
02-19 23:59:34.210: E/AndroidRuntime(18485): at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
02-19 23:59:34.210: E/AndroidRuntime(18485): at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1706)
02-19 23:59:34.210: E/AndroidRuntime(18485): at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1654)
02-19 23:59:34.210: E/AndroidRuntime(18485): at com.kaizendroid.bc.DataHandler.updatedata(DataHandler.java:122)
02-19 23:59:34.210: E/AndroidRuntime(18485): at com.kaizendroid.bc.MyTestService.getbcfromcloud(MyTestService.java:169)
02-19 23:59:34.210: E/AndroidRuntime(18485): at com.kaizendroid.bc.MyTestService.get_local_cloud_compare(MyTestService.java:70)
02-19 23:59:34.210: E/AndroidRuntime(18485): at com.kaizendroid.bc.MyTestService.onHandleIntent(MyTestService.java:49)
02-19 23:59:34.210: E/AndroidRuntime(18485): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
02-19 23:59:34.210: E/AndroidRuntime(18485): at android.os.Handler.dispatchMessage(Handler.java:102)
02-19 23:59:34.210: E/AndroidRuntime(18485): at android.os.Looper.loop(Looper.java:146)
02-19 23:59:34.210: E/AndroidRuntime(18485): at android.os.HandlerThread.run(HandlerThread.java:61)
Aucun commentaire:
Enregistrer un commentaire