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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:30:24+00:00 2026-05-28T01:30:24+00:00

I am developing one application. In that iam facing the problem at inserting the

  • 0

I am developing one application. In that iam facing the problem at inserting the data into database. First insert and update will be performed very well. After updating if i want to perform insert operation then app will be crashed. My code for inserting and updating were like below

+(BOOL)update:(CalendarInfo*)clInfo
{
    NSString *query = [NSString stringWithFormat:@"UPDATE ABC set A = '%@' where B =%d and C=%d",clInfo.a,clInfo.b,clInfo.c]; 
    sqlite3_stmt *stStatement;

    if(sqlite3_prepare_v2(database, [query UTF8String], -1, &stStatement, nil)==SQLITE_OK)
    {
        if(SQLITE_DONE == sqlite3_step(stStatement))
            NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database));
        else
            NSLog(@"updation  Successful");
    }
    return 0;
}

+(BOOL)insert:(CalendarInfo*)clInfo{

    sqlite3_stmt *addStmt = nil;
    sqlite3 *contactDB;
    NSArray *docPathArr = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *destPath = [NSString stringWithFormat:@"%@/example.sqlite",[docPathArr objectAtIndex:0]];

    if (sqlite3_open([destPath UTF8String], &contactDB)==SQLITE_OK) {
        NSString *query2 = [NSString stringWithFormat:@"INSERT  INTO ABC(C,B,A) VALUES(%d,%d,'%@')",clInfo.c,clInfo.b, clInfo.a];
        if(sqlite3_prepare_v2(database,  [query2 UTF8String], -1, &addStmt, NULL) != SQLITE_OK)
            NSAssert1(0, @"Error while creating add statement. '%s'", sqlite3_errmsg(database));
    }

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

    sqlite3_reset(addStmt);

    return 0;
}

So please tell me how to solve my problem.

  • 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-28T01:30:25+00:00Added an answer on May 28, 2026 at 1:30 am

    From the limited code you’ve posted, I think the answer has to do with that you have two different sqlite3 instances here. Was this intentional?

    You call sqlite3_open([destPath UTF8String], &contactDB);

    and then attempt to get an error result off another sqlite instance:

    sqlite3_errmsg(database)
    

    Either use database or contactDB and you should be all set.

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

Sidebar

Related Questions

I'm looking into developing an application that will process data from a line-scan camera
iam developing one application.In that i use the search bar for search the data.But
iam developing one application.In that i want to find out the x,y,z axis values
I am developing one GPS Application. Which will send the location data to server
I am developing an application based on one library. I am facing problem related
iam developing one application.In that i place the imageview in every tableview cell like
iam developing one application.In that i use the label and textfield in same line.Every
Iam developing one applciation.In that application i used the both imageview and textview.And iam
Iam developing one application.In that i want to use the Amazon S3 service.I got
Iam developing one application.In that i use the google api for getting the location

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.