insert data using sqlite issue on iphone ( not reflecting on table)

Posted by prajakta on Stack Overflow See other posts from Stack Overflow or by prajakta
Published on 2010-12-27T07:33:41Z Indexed on 2010/12/28 10:54 UTC
Read the original article Hit count: 207

Filed under:

i can insert my data but i cant show them on my table view ..i did [tableview reload data] but of no success

here is my code

-(void)gButtonTapped:(id)sender
{  


    NSLog(@"right nav bar button is  hit%@ ",storePaths);
    //[self readAnimalsFromDatabase2];

    appDelegate = (DatabaseTestAppDelegate *)[[UIApplication sharedApplication] delegate];
    sqlite3 *database;

     sqlite3_stmt *compiled_statement1;
     if(sqlite3_open([storePaths UTF8String], &database) == SQLITE_OK) {
     //const char *sqlStatement = 


     NSString *newQuery = [NSString stringWithFormat:@"insert into cat_tbl (cat_id,names,imgs) values ('12','test1','r.png')"];

        // NSString *newQuery = [NSString stringWithFormat:@"select * from list_tbl"];

         const char *sql = [newQuery cStringUsingEncoding:NSASCIIStringEncoding];


         NSLog(@"update query is %@",newQuery);

     if(sqlite3_prepare_v2(database, sql, -1, &compiled_statement1, NULL) == SQLITE_OK)


     {
         int result = sqlite3_step(compiled_statement1);
         sqlite3_reset(compiled_statement1);
         NSLog(@"result %d", result);

         if(result != SQLITE_ERROR) {
             int lastInsertId =  sqlite3_last_insert_rowid(database);
             NSLog(@"x %d", lastInsertId);
         }




     }

         }

         sqlite3_finalize(compiled_statement1);


    sqlite3_close(database);
    [tabelView reloadData];// this is also  not working 

}

© Stack Overflow or respective owner

Related posts about iphone-sdk-3.0