Sqlite database doesn't update the data from web services

I am doing an app which gets JSON datas from the web service and update it in the SQLite database. My problem is i got the values from web services but while uploading it shows 'null'. its not getting updated.

my code:-

-(void) updateSignupTable: (NSDictionary*) json {
    //copying the values from web services

    NSString *balance =  [json objectForKey:@"balance"];
    NSString *phone_number =[json objectForKey:@"sim_number"];
    NSString *call_forward_Status = [json objectForKey:@"call_forward_status"];

//Storing it in the database

    sqlExecutObj.sql=[NSString stringWithFormat:@"UPDATE profile_table SET phone_number ='%@' balance = '%@' call_forward_status = '%@' WHERE profile_name= '%@'", phone_number ,balance, call_forward_Status, profileDetailTitle];

    sqlExecutObj.dataTypeArray=[[NSMutableArray alloc]initWithObjects:@"1",@"1",@"1",nil];

    [sqlExecutObj executeSelectQuery];
///reloading the table    
    [profileDetailView.detailsTableView reloadData];

    // fetch and print the  updated datas from SQLite

    sqlExecutObj.sql=[NSString stringWithFormat:@"SELECT call_forward_status,phone_number,balance FROM profile_table WHERE profile_name= '%@'",selectedProfileName];

    sqlExecutObj.dataTypeArray=[[NSMutableArray alloc]initWithObjects:@"1",@"1",@"1",nil];

    [sqlExecutObj executeSelectQuery];

    NSLog(@"result from table are: %@. and  %@, and %@", [[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 from table are: (null). and  (null), and (null)

Answers


Just to be cautious, the following line:

 sqlExecutObj.sql=[NSString stringWithFormat:@"UPDATE profile_table SET phone_number ='%@' balance = '%@' call_forward_status = '%@' WHERE profile_name= '%@'", phone_number ,balance, call_forward_Status, profileDetailTitle];

Specifies 'profileDetailTitle as the profile_name, but the second statement, where you're reading the data from the database:

sqlExecutObj.sql=[NSString stringWithFormat:@"SELECT call_forward_status,phone_number,balance FROM profile_table WHERE profile_name= '%@'",selectedProfileName];

Specifies that the profile_name is 'selectedProfileName'.

In your code, it's not obvious what either profileDetailTitle, or selectedProfileName is. Perhaps for the sake of debugging, you set them both to the same value.

Also, just to be sure, if either the profileDetailTitle or selectedProfileName is user-driven, or maybe just contains non-alphanumeric characters, you should be (either) binding, sanity checks, escaping those values. The same goes for any other values being input into the database - but this is not to scope ;-)


Need Your Help

How to modify builder pattern by adding more keys?

java enums builder

I am working on a project in which I need to make a keys by passing different parameters to it so I decided to use Builder pattern here.

Can I remove transients in the wp_options table of my WordPress install?

mysql database wordpress wordpress-plugin

I have recently noticed that my wp_options table seems to be a bit large. It contains 1161 rows, and is about 2.1mb in size.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.