android - Update query is not working in sqlite -
i have update query in android application. not working properly. when clicking button updating application stops working. code follows-
update.setonclicklistener(new onclicklistener (){ @override public void onclick(view v) { // todo auto-generated method stub string feched_name = show_name.gettext().tostring(); string get_std_for_update=id_search.gettext().tostring(); string get_new_name = id_update.gettext().tostring(); if(feched_name.matches("")){ toast.maketext(getapplicationcontext(), "no student selected", toast.length_long).show(); } else { if(get_new_name.matches("")){ toast.maketext(getapplicationcontext(), "new name empty", toast.length_long).show(); } else{ stddb.execsql("update student set name = "+get_new_name + "where id = "+get_std_for_update); toast.maketext(getapplicationcontext(), "student's name has been updated", toast.length_long).show(); } } } });
replace query below existing 1 :
stddb.execsql("update student set name = '"+get_new_name + "' id = "+get_std_for_update);
mark single quote around name , space.
hope helps.
Comments
Post a Comment