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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:21:33+00:00 2026-06-05T01:21:33+00:00

I have an iPad app that is using a sqlite database using FMDB as

  • 0

I have an iPad app that is using a sqlite database using FMDB as a wrapper. I am able to successfully query data from the database; however when I attempt to insert data using executeUpdate, the method fires correctly (i.e. I get no errors and it returns YES) but nothing is actually inserted into the database. I try to immediately retrieve the object I just inserted and it is null. I also try to look at the number of rows in the table I inserted to and the table is empty. Any idea what I’m doing wrong? Here’s some of the code:

–init method of the class that handles all my db work

    -(NSString *)getDbPath {    
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,     NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        return [documentsDirectory stringByAppendingPathComponent:@"iRecipeBox.db"];
     }

    -(id)init {
        self = [super init];
        if(self) {
           database = [FMDatabase databaseWithPath:[self getDbPath]];
           [database open];
        }

       return self;
     }

–App delegate code that moves my db into the docs directory

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        // Override point for customization after application launch.
        NSFileManager *fileManager = [NSFileManager defaultManager];
        NSError *error;
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];

        NSString *docsPath = [documentsDirectory stringByAppendingPathComponent:@"iRecipeBox.db"];

        if ([fileManager fileExistsAtPath:docsPath] == NO) {
            NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"iRecipeBox" ofType:@"db"];
            [fileManager copyItemAtPath:resourcePath toPath:docsPath error:&error];
         }
         return YES;

}

–Code to insert data into one of the tables

    recipeID = [NSNumber numberWithInt:newRecipeID];
    [database beginTransaction];
    NSArray *newRow = [[NSArray alloc] initWithObjects:recipeID,title, description, picFile, prepTime, cookTime, ovenTemp, nil];
    NSString *sql = @"insert into recipes (id, name, descr, picFile, prepTime, cookTime, ovenTemp) values (?, ?, ?, ?, ?, ?, ?)";
    NSLog(@"Before update, the number of args is %i", [newRow count]);

    if([database executeUpdate:sql withArgumentsInArray:newRow]) {
        [database commit];
        NSLog(@"the insert worked");
    } else {
        [database rollback];
        NSLog(@"the insert failed");
    }
  • 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-05T01:21:34+00:00Added an answer on June 5, 2026 at 1:21 am

    [FMDatabase databaseWithPath:] returns an autoreleased object, so you’re going to want to retain that if you’re not using ARC.

    Check [database lastError] right after the executeUpdate:, and see if it says anything.

    And finally- there’s no point in using a transaction if it’s just a single insert.

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

Sidebar

Related Questions

I have an iPad app that receives data using UDP sockets. And it has
I have an iPad app that I submitted to Apple successfully using my personal
I have this iPad app using Storyboard. There are some file that are marked
I have installed my enterprise iPad App using itunes successfully. When I have made
I have a Core Data app that will end up being an iPhone/iPad universal
I have an iPad app that I would like to make Universal, however this
I wanted auto completion feature in ipad app. I have a sqlite database of
I have a graphic-intensive iPad app that features a UIWebView. Using the simulator (iOS
we have an iPad app crashing without. However it is a universal app using
I have a core data app that I am using with a sql lite

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.