Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8581265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:00:23+00:00 2026-06-11T21:00:23+00:00

I have an sqlite database and it’s loaded into a tableview, now when i

  • 0

I have an sqlite database and it’s loaded into a tableview, now when i click a row to see its details..i go to another view controller in which details are displayed and a AddToFav button exists.
When i click it..and go to another view controller…i can see the changes correctly, my database is updating correctly, but if i try to add another entry..i notice that my database is not updated anymore..The addToFav button only updates the database once. Any ideas?
This is my Addbut IBaction :

- (IBAction)AddButClick:(UIButton *)sender {



    [AddBut setImage:[UIImage imageNamed:@"apple-logo copy.png"] forState:UIControlStateSelected];
    [AddBut setImage:[UIImage imageNamed:@"apple-logo copy.png"] forState:UIControlStateHighlighted];
    Favo = [[NSMutableArray alloc] initWithCapacity:1000000];



    @try {
      //  NSFileManager *fileMgr = [NSFileManager defaultManager];
        // NSString *dbPath = [[[NSBundle mainBundle] resourcePath ]stringByAppendingPathComponent:@"dictionary.sqlite"];
        //NSString *dbPath = [[[NSBundle mainBundle] resourcePath ]stringByAppendingPathComponent:@"authorsDb2.sqlite"];
        //     NSString *dbPath = [[[NSBundle mainBundle] resourcePath ]stringByAppendingPathComponent:@"FinalDb.sqlite"];
        //NSString *dbPath = [[[NSBundle mainBundle] resourcePath ]stringByAppendingPathComponent:@"xxJuridique-FINAL-OK.sqlite"];
     //   [self createEditableCopyOfDatabaseIfNeeded];


   //     NSString *dbPath = [[[NSBundle mainBundle] resourcePath ]stringByAppendingPathComponent:@"data.sqlite"];
      //  [self.tableView reloadData];

        sqlite3_stmt *compiled_statement1;

        if(sqlite3_open([PathDB UTF8String], &db) == SQLITE_OK) {



//            UIAlertView *DbO = [[UIAlertView alloc]
//                                 initWithTitle:@"PATH" message:@"Database still open !" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
//            
//            [DbO show];
            NSString *formatedSql = [NSString stringWithFormat:@"UPDATE Sheet1 SET Fav = 'YES' WHERE field3 = '%@'" , authorNAme2];

//            UIAlertView *messageAlert = [[UIAlertView alloc]
//                                         initWithTitle:@"Query" message:formatedSql delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
//            
//            [messageAlert show];
//            
            UIAlertView *PAth = [[UIAlertView alloc]
                                 initWithTitle:@"PATH" message:PathDB delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];

            [PAth show];
           // NSLog(PathDB);

            const char *sql = [formatedSql UTF8String];
            NSLog(@" !!!!!!!! In the middle of it !!!!!!!!!!!!");
            if (sqlite3_prepare_v2(db, sql, -1, &compiled_statement1, NULL) != SQLITE_OK) {
                NSLog(@"!!!!!!!!!!!!!!!!!!!ERRRRROOOOOOORRRRRRRRR!!!!!!!!!!!!!!!!!!!!!!!!!");
                //NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
            }

            NSLog(@"This is the query %@",formatedSql);

        }
   //     sqlite3_bind_text(compiled_statement1, 1, [authorNAme2 UTF8String], -1, SQLITE_TRANSIENT);


        int success = sqlite3_step(compiled_statement1);

        // sqlite3_reset(compiled_statement1);
        if (success != SQLITE_ERROR) {
            NSLog(@"Successfully inserted");
            sqlite3_last_insert_rowid(db);
        }

//        
//        BOOL success = [fileMgr fileExistsAtPath:dbPath];
//        
//        if(!success)
//        {
//            NSLog(@"Cannot locate database file '%@'.", dbPath);
//        }
//        if(!(sqlite3_open([dbPath UTF8String], &db) == SQLITE_OK))
//        {
//            NSLog(@"An error has occured: %@", sqlite3_errmsg(db));
//            
//        }


        // const char *sql = "SELECT F_Keyword FROM wordss";  
        const char *sql = "SELECT * FROM Sheet1";
        NSLog(@"Successfully selected from database");
        sqlite3_stmt *sqlStatement;
        if(sqlite3_prepare(db, sql, -1, &sqlStatement, NULL) != SQLITE_OK)
        {
            NSLog(@"Problem with prepare statement:  %@", sqlite3_errmsg(db));


        }else{


            NSLog(@"Got in the else tag");

            while (sqlite3_step(sqlStatement)==SQLITE_ROW /*&& PAss == NO*/) {

                NSLog(@"Got in the while tag");

                Author * author = [[Author alloc] init];
                NSLog(@"Author initialized");

                author.name = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement,10)];
                NSLog(@"Initialization ok");
           //     NSLog(author.name);

                if(/*author.name == @"NO" &&*/ HighLighted == NO){
                    //const char *sql2 = "INSERT INTO Sheet1 ";

                    [AddBut setImage:[UIImage imageNamed:@"apple-logo copy.png"] forState:UIControlStateNormal];
                    NSLog(@"We have not selected it as fav yet");
                  //  [AddBut setSelected:NO]; //btn changes to normal state
                    NSLog(@"The button was NOt highlighted and now is");
                    HighLighted = YES;
                     break;

                }

                else
                {

                    NSLog(@"We have selected it as fav");

                    [AddBut setImage:[UIImage imageNamed:@"apple-logo.png"] forState:UIControlStateNormal];
                    [AddBut setSelected:NO]; //btn changes to normal state
                    NSLog(@"The button was highlighted and now is NOt");


                    HighLighted = NO;
                     break;

                   // [self viewDidLoad];
                  //  PAss = YES;

                }
         //       [Favo release];

         //       NSLog(Favo);

//                author.name = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement,2)];
//                author.title = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement,2)];
//                author.genre = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement, 4)];
//                [theauthors addObject:author];
            }
        }
    }
    @catch (NSException *exception) {

        NSLog(@"Problem with prepare statement:  %@", sqlite3_errmsg(db));

    }
    @finally {
        //   sqlite3_finalize(sqlStatement);
     //   sqlite3_close(db);

        UIAlertView *fin = [[UIAlertView alloc]
                                                initWithTitle:@"Query" message:@"DOne with Click Button" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];

                   [fin show];

        return Favo;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:00:24+00:00Added an answer on June 11, 2026 at 9:00 pm

    Thank you @crazyCreator for your answer !!!!

    [self authorList2];
    [self.tableView reloadData];

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SQLite Database with 5000 rows that is loaded into a tableview.
I have an SQLite database with a simple table of Persons. Each row represents
I have a SQLite-Database and I did it into a QSqlTableModel . To show
I have a SQLite database that is displayed in a data grid view in
I have a Sqlite database in Android and I want to display its content
I have a SQLite database of notes that have columns _id, title, details, listid
I have sqlite database with table of songs, now I want to get artist
I have a sqlite database. I have three columns:_id, date, value. I now want
I have my sqlite database. now i want syncing with icloud. I read blogs
I have an sqlite database I want to distribute with my application. It's about

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.