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

  • Home
  • SEARCH
  • 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 8298983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:58:58+00:00 2026-06-08T15:58:58+00:00

i am inserting data into data base using following code but data is not

  • 0

i am inserting data into data base using following code but data is not inserted in the database
i am using following code

I am inserting data into iphone application but it does not insert

i have table survey_question_master(question_id,question_text,question_type)

- (void) addCoffee {
    if(addStmt == nil) {
        const char *sql = "insert into survey_question_master(question_text,question_type) Values( ? ,?)";

        if(sqlite3_prepare_v2(database, sql, -1, &addStmt, NULL) != SQLITE_OK)
            NSAssert1(0, @"Error while creating add statement. '%s'", sqlite3_errmsg(database));
    }

    sqlite3_bind_text(addStmt, 1, [question_text UTF8String], -1, SQLITE_TRANSIENT);
    sqlite3_bind_text(addStmt, 2, [question_type UTF8String], -1, SQLITE_TRANSIENT);

    if(SQLITE_DONE != sqlite3_step(addStmt))
        NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database));
    else
        question_ID = sqlite3_last_insert_rowid(database);

    //Reset the add statement.
    sqlite3_reset(addStmt);
}



   - (void) addCoffee:(DataController *)coffeeObj {

    //Add it to the database.
    [coffeeObj addCoffee];
   //Add it to the coffee array.
    [coffeeArray addObject:coffeeObj];
     NSLog(@"Succeessfully Added");
    }
  • 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-08T15:59:00+00:00Added an answer on June 8, 2026 at 3:59 pm
    - (NSString *) getDBPath 
    {
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
        NSString *documentsDir = [paths objectAtIndex:0];
        return [documentsDir stringByAppendingPathComponent:@"database.sqlite"];
    }
    
    -(void)SaveData:(NSMutableArray *)insertDataArray
    {
    
        sqlite3_stmt *stmt;
        const char *dbPath = [[self getDBPath] UTF8String];
        if(sqlite3_open(dbPath, &database)==SQLITE_OK)
        {
            NSString *insertSQL = [NSString stringWithFormat:@"insert into items (c1,c2,c3,c4 , c5 ,c6,c7,c8,c9) values (\"%@\",\"%@\",\"%@\",\"%@\",\"%@\",\"%@\",\"%@\",\"%@\",\"%@\")",[insertDataArray objectAtIndex:0],[insertDataArray objectAtIndex:1],[insertDataArray objectAtIndex:2],[insertDataArray objectAtIndex:3],[insertDataArray objectAtIndex:4],[insertDataArray objectAtIndex:5],[insertDataArray objectAtIndex:6],[insertDataArray objectAtIndex:7],[insertDataArray objectAtIndex:8]];
    
            NSLog(@"%@",insertSQL);
            const char *insert_stmt = [insertSQL UTF8String];
            sqlite3_prepare_v2(database, insert_stmt, -1, &stmt, NULL);
    
            if(sqlite3_step(stmt)==SQLITE_DONE)
            {
                NSLog(@"insert success");
            }
            else
            {
                NSLog(@"insert un success");
                NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
            }
            int success=sqlite3_step(stmt);
    
            if (success == SQLITE_ERROR) 
            {
                NSAssert1(0, @"Error: failed to insert into the database with message '%s'.", sqlite3_errmsg(database));
            }        sqlite3_finalize(stmt);
            sqlite3_close(database);
    
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code for inserting data into database using PDO. It inserts data
I am inserting data into my database using the following code: $this->db->set('event_id', $event_id); ...
In my c# application i am inserting data into sqlite database as below String
I am wanting to insert a datetime into a MySql data base using Java
I am inserting data into a mySQL database, but I am inserting banking details
I am getting the following error when inserting data into my oracle database. java.sql.SQLException:
I am inserting data into SQL 2005 using SQLXMLBulkLoad.SQLXMLBulkload.3.0 My data table has following
i'm trying to learn php/mysql. inserting data into mysql works fine but inserting those
I am inserting some data into an array but I am getting ,9,My firstname,My
I get the following error when inserting data from mysql into postgres. Do I

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.