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 6078873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:52:56+00:00 2026-05-23T10:52:56+00:00

Hi i am working with sqlite and i have added the data into the

  • 0

Hi i am working with sqlite and i have added the data into the database successfully, but the problem is that when i delete some data in some other table view and navigate back to my main view and i press the UIBarButton to call a function which again checks for the data in the database.

Now my problem is that the data which is newly displayed in the table is the one which got deleted so i tried to print my mutable array and in the log i see that their is no such data but then too in the table view cell i see that data. given below is my code to read the data in the db

NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDir = [documentPaths objectAtIndex:0];
   NSString *databasePath =  [documentsDir stringByAppendingPathComponent:@"PotsDB.sqlite"];

    sqlite3 *database;

    if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
        // Setup the SQL Statement and compile it for faster access
        const char *sqlStatement = "SELECT potsName FROM potsDetail;";
        sqlite3_stmt *compiledStatement;
        if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
            while(sqlite3_step(compiledStatement) == SQLITE_ROW) {


                NSString *Potname=[NSString stringWithUTF8String:(char *) sqlite3_column_text(compiledStatement, 0)];
                NSString * pname = [[NSString alloc]initWithFormat:@"%@",Potname];
                [potsArray addObject:pname];
                 NSLog(@"The data in the array is %@",potsArray);

            }
        }
        // Release the compiled statement from memory
        sqlite3_finalize(compiledStatement);
    }
    sqlite3_close(database);

Also heres the code that i am calling on the refresh button

-(IBAction)RefreshButtonTouched
{
    [potsArray removeAllObjects];
    [self Read_Potname_FromDB];
    [potsTableView reloadData];
}

The delete query that i am writing, i think i am doing some mistake with delete here

NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDir = [documentPaths objectAtIndex:0];
    NSString *databasePath =  [documentsDir stringByAppendingPathComponent:@"PotsDB.sqlite"];

    sqlite3 *database;

    if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
        // Setup the SQL Statement and compile it for faster access
        NSString *deleteStatement = [NSString stringWithFormat:@"delete from potsDetail where potsName = '%@'",sptr];
        const char *sqlStatement = [deleteStatement cStringUsingEncoding:NSASCIIStringEncoding];
        sqlite3_stmt *compiledStatement;

        if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
            while(sqlite3_step(compiledStatement) == SQLITE_ROW) {

                NSString *Potname=[NSString stringWithUTF8String:(char *) sqlite3_column_text(compiledStatement, 0)];
                NSString * pname = [[NSString alloc]initWithFormat:@"%@",Potname];
                [potsArray addObject:pname];
                //[pname release];
            }
        }
        // Release the compiled statement from memory
        sqlite3_finalize(compiledStatement);
    }
    sqlite3_close(database);

Please help me out am pretty messed up with this. Thanks in advance

  • 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-05-23T10:52:56+00:00Added an answer on May 23, 2026 at 10:52 am

    There are two cases that can happen here:

    1) Data is actually not deleted because You might have not called “sqlite3_finalize(compiledStatement);” statement, which is responsible to commit any transaction.

    2) UITableView is not reloaded, did you try using “[tableView reloadData];” on click of UIBarbuttonItem?

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

Sidebar

Related Questions

I'm working on an Android application that stores data in a SQLite database. My
I have created one application, where I am storing the data into database and
I'm trying to add a new entry into my database, but it's not working.
I am working on iOS5.I am new for SQLite. I have created database named
I have a database that has lots of data and is all neat, normalized
I am working on SQLite File Encryption . I have added sqlCipher & crypto
I'm working with sqlite and qt. I understand that sqlite doesn't have native user
I have a SQLite database that I am creating in my iOS application. A
I am working with SQLite. Suppose I have a table sales with two columns,
I am working on an app that will be pulling data from a SQLite

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.