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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:04:16+00:00 2026-06-01T11:04:16+00:00

Working on a simple TimeTracker App. You start a timer, wait a certain time,

  • 0

Working on a simple TimeTracker App. You start a timer, wait a certain time, stop the clock and save spent minutes to a SQLite3 database. All is working as expected, when I tap on save I get a confirmation that record was saved but I can’t get the saved entries shown on the console. As seen in the screenshot below I have a show button which should show me all my saved entries in the console including timestamp but nothing happens when I tap the button.

I think the problem is related to the search query but I can’t figure our whats wrong.

From my understanding the query is looking for the timestamp (column 0) and the spent minutes (column 1) but it doesn’t work, please help.

   NSLog(@"Timestamp: %s - Timing: %s", sqlite3_column_text(statement, 0), sqlite3_column_text(statement, 1));

SQLite database is really simple, I only want to save one value > spent minutes.
Maybe the database is not created correctly??

Database Creation:

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSString *docsDir;
    NSArray *dirPaths;

    dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    docsDir = [dirPaths objectAtIndex:0];

    databasePath = [[NSString alloc]initWithString:[docsDir stringByAppendingPathComponent:@"timings.db"]];

    NSFileManager *filemgr = [NSFileManager defaultManager];

    if ([filemgr fileExistsAtPath:databasePath] == NO) 
    {
        const char *dbPath = [databasePath UTF8String];

        if (sqlite3_open(dbPath, &timings) == SQLITE_OK) 
        {
            char *errormsg;
            const char *sql_stmt =
            "CREATE TABLE IF NOT EXISTS TIMINGS(ID INTEGER PRIMARY KEY AUTOINCREMENT, TIME INTEGER)";

            if (sqlite3_exec(timings, sql_stmt, NULL, NULL, &errormsg) != SQLITE_OK) 
            {
                self.statusLabel.text = @"Failed to create database";
            }
            sqlite3_close(timings);
        } 
        else 
        {
            self.statusLabel.text = @"Failed to open/create database.";
        }

    }
}

Show saved entries on console:

-(IBAction)showButton:(id)sender
{
    if (sqlite3_open([databasePath UTF8String], &timings) == SQLITE_OK)
    {
        NSString *queryStatement = [NSString stringWithFormat:@"SELECT TIMESTAMP, TIME FROM TIMINGS"];

        sqlite3_stmt *statement;
        if (sqlite3_prepare_v2(timings, [queryStatement UTF8String], -1, &statement, NULL) == SQLITE_OK)
        {
            while (sqlite3_step(statement) == SQLITE_ROW) {
                NSLog(@"Timestamp: %s - Timing: %s", sqlite3_column_text(statement, 0), sqlite3_column_text(statement, 1));
            }
            sqlite3_finalize(statement);
            sqlite3_close(timings);
        }
    }
}

Screernshot

  • 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-01T11:04:17+00:00Added an answer on June 1, 2026 at 11:04 am

    a friend of mine just realized that I made a big mistake, I totally forgot to CREATE the column ‘TIMESTAMP’ I’m trying to read out here. If you look at this line: "CREATE TABLE IF NOT EXISTS TIMINGS(ID INTEGER PRIMARY KEY AUTOINCREMENT, TIME INTEGER)"; You see that I have not created the timestamp column. Last but not least is TIMESTAMP a protected keyword in SQL you are not allowed to use. To save a timestamp I just created and renamed the column and now it’s working. Thanks for all your help.

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

Sidebar

Related Questions

i am working on a simple web app which has a user model and
hi iam currently working in simple amimation app in which i implement following code
Am working on simple utility app with picker, but the message does not output
I'm working on simple videochat app with Adobe FMS 4.5. Everything works fine except
I'm looking for good/working/simple to use PHP code for parsing raw email into parts.
The simple working query, list the number of licenses for each license type: Query:
Working on a simple C program I'm stuck with an if test: int line_number
im working on a simple C++ HTTP server as a school project and I
im working on a simple game like space invaders,and i got into a problem.
I'm working on a simple ASP.Net page (handler, actually) where I check the value

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.