java - Activity getting stopped with CursorIndexOutOfBounds Exception -


hi guys facing error while compiling code , couldn't understand mean..i need assistance..

giving codes below..

            public string  updateentry(string empcode,string confirm_password)              {        string update="update signup set password = '" + confirm_password + "' " + "         employee_code = " + " '" + empcode + "' ";          cursor cursor=db.rawquery(update, null);          string uppassword=cursor.getstring(cursor.getcolumnindex("password"));          return uppassword;             } 

the code returns correct output ...but error exists..and activity getting stopped..

giving logcat below..

10-07 08:34:09.474: e/androidruntime(21657): android.database.cursorindexoutofboundsexception: index -1 requested, size of 0  10-07 08:34:09.474: e/androidruntime(21657):    @ android.database.abstractcursor.checkposition(abstractcursor.java:424)  10-07 08:34:09.474: e/androidruntime(21657):    @  android.database.abstractwindowedcursor.checkposition(abstractwindowedcursor.java:136)  10-07 08:34:09.474: e/androidruntime(21657):    @ android.database.abstractwindowedcursor.getstring(abstractwindowedcursor.java:50)  10-07 08:34:09.474: e/androidruntime(21657):    @ com.neochat.logindatabaseadapter.updateentry(logindatabaseadapter.java:145)  10-07 08:34:09.474: e/androidruntime(21657):    @ com.neochat.forgotpassword.attemptforgot(forgotpassword.java:157)  10-07 08:34:09.474: e/androidruntime(21657):    @ com.neochat.forgotpassword$1.onclick(forgotpassword.java:54)  10-07 08:34:09.474: e/androidruntime(21657):    @ android.view.view.performclick(view.java:4204)  10-07 08:34:09.474: e/androidruntime(21657):    @ android.view.view$performclick.run(view.java:17355)  10-07 08:34:09.474: e/androidruntime(21657):    @ android.os.handler.handlecallback(handler.java:725)  10-07 08:34:09.474: e/androidruntime(21657):    @ android.os.looper.loop(looper.java:137)  10-07 08:34:09.474: e/androidruntime(21657):    @ android.app.activitythread.main(activitythread.java:5041)  10-07 08:34:09.474: e/androidruntime(21657):    @ java.lang.reflect.method.invokenative(native method)  10-07 08:34:09.474: e/androidruntime(21657):    @ java.lang.reflect.method.invoke(method.java:511)  10-07 08:34:09.474: e/androidruntime(21657):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793)  10-07 08:34:09.474: e/androidruntime(21657):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560) 10-07 08:34:09.474: e/androidruntime(21657):    @ dalvik.system.nativestart.main(native method) 

you can't call getstring on update command. that'll work select command


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -