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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:32:16+00:00 2026-06-18T01:32:16+00:00

I insert data in the sqlite database and in the second tab I display

  • 0

I insert data in the sqlite database and in the second tab I display the insert data into grouped table view, but the last data I insert doesn’t display in the table view, although when I run the app again all data is shown, How I can display all the insert data in the table view??

This my code for select Name and amount from Expense table

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    }

    NSInteger section = [indexPath section];
    NSInteger row = [indexPath row];
    NSLog(@"sec%i",section);
    NSLog(@"row%i",row);
    NSMutableArray *NAMeA= [[NSMutableArray alloc]init ];
    NSMutableArray *DateA= [NSMutableArray array];
    if (sqlite3_open([[AppDelegate getDBPath] UTF8String], &database) == SQLITE_OK) {
        const char *sql ="select ExpenseMonth,count(*) as day from Expense  where strftime('%m',ExpenseMonth)=strftime('%m','now') group by ExpenseMonth order by ExpenseMonth desc";

        sqlite3_stmt *selectstmt;
        int result = sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL);
        if( result== SQLITE_OK) {
            while(sqlite3_step(selectstmt) == SQLITE_ROW) {

                NSString *dateAndTime=[NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 0)];
                NSInteger numofday=sqlite3_column_int(selectstmt,1);

                MaxEntity *DatTime=[[MaxEntity alloc]initWithDate:dateAndTime andnumofDay:numofday];                
                [DateA addObject:DatTime];
                [NAMeA removeAllObjects];
                NSLog(@"Date %@",dateAndTime);
                NSString *querySQL =[NSString stringWithFormat:@"select Name, amount from Expense  where ExpenseMonth=\"%@\" order by ExpenseMonth desc",dateAndTime];
                const char *query_stmt = [querySQL UTF8String];
                sqlite3_stmt *selectstm = NULL;
                int result = sqlite3_prepare_v2(database, query_stmt, -1, &selectstm, NULL);
                if( result== SQLITE_OK) {
                    while(sqlite3_step(selectstm) == SQLITE_ROW) {
                        NSString *NAMe=[NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstm, 0)];
                        NSString *Amount=[NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstm, 1)];
                        MaxEntity *NM=[[MaxEntity alloc]initWithName:NAMe andAmount:Amount];
                        [NAMeA addObject:NM];
                        NSLog(@"text%@",NAMe);

                        if ([indexPath section]+1 ==[DateA count] && [indexPath row]+1==[NAMeA count]) {
                            cell.textLabel.text =NM.name;
                            cell.detailTextLabel.text = NM.amountD;
                            NSLog(@"%@ name",NM.name);

                        }
                    }
                }
                sqlite3_finalize(selectstm);
            }
        }else {
            NSLog(@"failed to prepare %d",result);
        }
    }
    else{

        NSLog(@"Faile to open db");
        sqlite3_close(database);
       [self.table reloadData];

    }
    self.NameArray =NAMeA ;

    self.DateArray = DateA;
       [self.table reloadData];

    return cell;
}
  • 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-18T01:32:17+00:00Added an answer on June 18, 2026 at 1:32 am

    As already said in comments..

    to update de table when your tab appear, add in your implementation file of second tab:

    - (void)viewWillAppear:(BOOL)animated{
    
           [super viewWillAppear:animated];
           NSLog(@"updateTable");
    
         [self.table reloadData];
        //or - depend of your your conf
        //[self.tableView reloadData];
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to insert data into the SQLite database using get EditText, but I
I'm trying to insert some data into my SQLite database. But I keeo receiving
I insert data into sqlite database table and when i insert first record ,
I am trying to insert data into a SQLite database that is used for
I have written the code to insert the data into SQLite database at that
I am trying to insert data into my SQLite database. I have imported all
I am using following query to insert data into a SQLite database for Android.
Suppose I insert a data point into a sqlite3 database on a nightly basis.
I am trying to insert data to a new empty table. But I keep
I am trying to insert data from a database into a textarea. I can't

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.