iphone - Sqlite database doesn't update the data from web services -


i doing app gets json datas web service , update in sqlite database. problem got values web services while uploading shows 'null'. not getting updated.

my code:-

-(void) updatesignuptable: (nsdictionary*) json {     //copying values web services      nsstring *balance =  [json objectforkey:@"balance"];     nsstring *phone_number =[json objectforkey:@"sim_number"];     nsstring *call_forward_status = [json objectforkey:@"call_forward_status"]; 

//storing in database

    sqlexecutobj.sql=[nsstring stringwithformat:@"update profile_table set phone_number ='%@' balance = '%@' call_forward_status = '%@' profile_name= '%@'", phone_number ,balance, call_forward_status, profiledetailtitle];      sqlexecutobj.datatypearray=[[nsmutablearray alloc]initwithobjects:@"1",@"1",@"1",nil];      [sqlexecutobj executeselectquery]; ///reloading table         [profiledetailview.detailstableview reloaddata];      // fetch , print  updated datas sqlite      sqlexecutobj.sql=[nsstring stringwithformat:@"select call_forward_status,phone_number,balance profile_table profile_name= '%@'",selectedprofilename];      sqlexecutobj.datatypearray=[[nsmutablearray alloc]initwithobjects:@"1",@"1",@"1",nil];      [sqlexecutobj executeselectquery];      nslog(@"result table are: %@. ,  %@, , %@", [[sqlexecutobj.result objectatindex:0] objectatindex:0],[[sqlexecutobj.result objectatindex:1] objectatindex:0],[[sqlexecutobj.result objectatindex:2]objectatindex:0] ); } 

my debug output:-

2013-05-14 15:54:02.910 movirtu[44262:19d03] result table are: (null). ,  (null), , (null) 

just cautious, following line:

 sqlexecutobj.sql=[nsstring stringwithformat:@"update profile_table set phone_number ='%@' balance = '%@' call_forward_status = '%@' profile_name= '%@'", phone_number ,balance, call_forward_status, profiledetailtitle]; 

specifies 'profiledetailtitle profile_name, second statement, you're reading data database:

sqlexecutobj.sql=[nsstring stringwithformat:@"select call_forward_status,phone_number,balance profile_table profile_name= '%@'",selectedprofilename]; 

specifies profile_name 'selectedprofilename'.

in code, it's not obvious either profiledetailtitle, or selectedprofilename is. perhaps sake of debugging, set them both same value.

also, sure, if either profiledetailtitle or selectedprofilename user-driven, or maybe contains non-alphanumeric characters, should (either) binding, sanity checks, escaping values. same goes other values being input database - not scope ;-)


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -