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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:04:19+00:00 2026-05-30T02:04:19+00:00

I am working on an offline-mode iPhone application in which the first time data

  • 0

I am working on an offline-mode iPhone application in which the first time data comes from the server in JSON format, I parse this data, store it into an mutable array, and then insert these array values into a sqlite database, but only one value or the last value is inserted.

Here is my code for insertion:

-(void)insertData {
  NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  NSString *documentsDir = [documentPaths objectAtIndex:0];
  NSString *databasePath=[documentsDir stringByAppendingPathComponent:@"paddleEight.sqlite"];
  NSLog(@"The Database Path is---> %@", databasePath);

  sqlite3 *database; 

  if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
    int i;  

    sqlite3_stmt *addStmt;
    NSString* sSqlSelect = [NSString stringWithFormat:@"insert into GalleryTabel(depth,imageUrl)VALUES(?,?);"];



    for (i = 1; i < [self.propertiesArray count]; i++)  
    {

        if(sqlite3_prepare_v2(database, [sSqlSelect UTF8String], -1, &addStmt, NULL) == SQLITE_OK)   
        {


            sqlite3_bind_text(addStmt, 1, [[[[[self.propertiesArray objectAtIndex:i]objectForKey:@"images"]objectForKey:@"primary"]objectForKey:@"type"] UTF8String],-1,SQLITE_TRANSIENT);
            sqlite3_bind_text(addStmt, 2, [[[[[self.propertiesArray objectAtIndex:i]objectForKey:@"images"]objectForKey:@"primary"]objectForKey:@"location"] UTF8String],-1,SQLITE_TRANSIENT);

        }

    }
    if(sqlite3_step(addStmt)==SQLITE_DONE) 
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Add Record" message:@"Contact Added" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];    
        [alert show];
        [alert release];
        alert=nil;

    }
    else 
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"record" message:@"record not created" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];   
        [alert show];
        [alert release];
        alert=nil;
    }

  }

}

Any help is highly appreciated. Thanks in Advanced:

  • 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-30T02:04:20+00:00Added an answer on May 30, 2026 at 2:04 am

    You prepare statement multiple times, but executing it only once.
    You should prepare statement once (in you case you’re using same SQL instruction), then bind parameters and execute statement for each array element instead.

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

Sidebar

Related Questions

I'm working on iphone application which needs to run offline at an exhibition. It
I'm working on an iPhone application that should work in offline and online modes.
I am working on facebook application. I am getting the offline access permission from
I'm working on a phonegap iPhone app which downloads content from the network in
Working with an Oracle 9i database from an ASP.NET 2.0 (VB) application using OLEDB.
I'm working on an offline only help system which requires loading a large amount
I'm working on a web app which will need to work offline. I'm looking
I'm working on an iPhone app in which I manage some kind of agendas.
I have an MVC2 web site which I am trying to get working offline
I'm working on an offline-capable application and I'd like to do an ajax call

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.