views:

336

answers:

1

Hey I am using the http://th30z.netsons.org/2008/11/objective-c-sqlite-wrapper/ wrapper .

My code is this :

    - (IBAction)UpdateButtonPressed:(id)sender 
    {


        Sqlite *sqlite = [[Sqlite alloc] init];
        NSString *writableDBPath = [[NSBundle mainBundle]pathForResource:@"Money"ofType:@"sqlite"];
        if (![sqlite open:writableDBPath])
            return;


        NSArray *query = [sqlite executeQuery:@"UPDATE UserAccess SET Answer ='Positano';"];
            NSDictionary *dict = [query objectAtIndex:2];
            NSString *itemValue = [dict objectForKey:@"Answer"];
            NSLog(@"%@",itemValue);
}

Answer is the Column name , UserAccess the table name . the column is at 3rd place in the table

What am I doing wrong why is it crashing ???

A: 

An update query does not return any results. You will typically use objectAtIndex after executing a SELECT query, but it won't work with UPDATE.

Shtong
[sqlite executeQuery:@"UPDATE UserAccess SET Answer ='Positano';"];NSArray *query2 = [sqlite executeQuery:@"SELECT Answer FROM UserAccess;"]; NSDictionary *dict = [query2 objectAtIndex:0]; NSString *itemValue = [dict objectForKey:@"Answer"]; NSLog(@"%@",itemValue);This worked for me thanks ... how stupid am I need to go through sql again . Do you know how can I accept it from UITextField >> updatefield.text