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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:37:21+00:00 2026-05-14T06:37:21+00:00

I am creating an exercise app that will record the weight used and the

  • 0

I am creating an exercise app that will record the weight used and the number of “reps” the user did in 4 “Sets” per day over a period of 7 days so the user may view their progress.

I have built the database table named FIELDS with 2 columns ROW and FIELD_DATA and I can use the code below to load the data into the db. But the code has a sql statement that says,

INSERT OR REPLACE INTO FIELDS (ROW, FIELD_DATA)VALUES (%d, '%@'); 

When I change the statment to:

INSERT INTO FIELDS (ROW, FIELD_DATA)VALUES (%d, '%@'); 

Nothing happens. That is no data is recorded in the db.

Below is the code:

#define kFilname @"StData.sqlite3"

- (NSString *)dataFilePath
{
  NSArray *paths = NSSearchPathForDirectoriesInDomains
    (NSDocumentDirectory, NSUserDomainMask, YES);
  NSString *documentsDirectory = [paths objectAtIndex:0];
  return [documentsDirectory stringByAppendingPathComponent:kFilname];
}

-(IBAction)saveData:(id)sender;
{

  for (int i = 1; i <= 8; i++)
  {
    NSString *fieldName = [[NSString alloc]initWithFormat:@"field%d", i];
    UITextField *field = [self valueForKey:fieldName];
    [fieldName release];

    NSString *insert = [[NSString alloc] initWithFormat:
        @"INSERT OR REPLACE INTO FIELDS (ROW, FIELD_DATA)
          VALUES (%d, '%@');",i, field.text];
    // sqlite3_stmt *stmt;

    char *errorMsg;

    if (sqlite3_exec (database, [insert UTF8String],
        NULL, NULL, &errorMsg) != SQLITE_OK)
    {
      // NSAssert1(0, @"Error updating table: %s", errorMsg);
      sqlite3_free(errorMsg);
    }  
  }
  sqlite3_close(database);    
}

So how do I modify the code to do what I want? It seemed like a simple sql statement change at first but obviously there must be more. I am new to Objective-C and iPhone programming.
I am not new to using sql statements as I have been creating web apps in ASP for a number of years.

Any help will be greatly appreciated, this is driving me nuts!

  • 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-14T06:37:22+00:00Added an answer on May 14, 2026 at 6:37 am

    Suggestions:

    • write an insert statement with hardcoded values to see if the insert works
    • your filename has no path. does it assume the current directory when executed? what directory is it running from?
    • write a message to the screen if possible to see what the values you’re getting are. Are they correct?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on creating an app that will parse MSDN articles for meta-information such
I need to write an app that that will iterate over our database, and
I am working on my first ever android app, and I'm creating basic exercise/calorie
As a training exercise, I am creating a counter that runs in a background
I'm practicing my Rails development skills by building an app that will have different
I am creating a user authentication library (for the exercise). One of the things
As a learning exercise, I am creating a program that converts characters entered through
I'm creating an app that is basically an extension of a tutorial (I am
I'm creating a blog engine as a learning exercise and one particular problem has
I am creating a clone of Space Invaders in XNA as an exercise. I've

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.