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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:09:25+00:00 2026-05-28T07:09:25+00:00

Been Trying for 8 hours, not too sure which part gone wrong. i know

  • 0

Been Trying for 8 hours, not too sure which part gone wrong. i know is the ID problem as i tried the last record. it is supposed to be ID 5, but the NSlog shows 6 instead.
i removed all the unique id, so is not reserve key problem.

thanks for looking.

Please help, i going crazy……..

- (id) initWithPrimaryKey:(NSInteger)pk
{   
    self = [super init];

    ID = pk;
    isDetailViewHydrated = NO;

    return self;

}

- (void)saveAllData
{
    if(isDirty) {

        if(updateStmt == nil) {

            const char *sql = "UPDATE identifyF SET TypeName = ?, gDate = ?, Location = ?, GeoCode = ?,Note = ?, Image = ?, TypeID = ? WHERE ID = ?";

            if(sqlite3_prepare_v2(database, sql, -1, &updateStmt, NULL) != SQLITE_OK)
                NSAssert1(0, @"Error while creating update statement. '%s'", sqlite3_errmsg(database));
        }
        sqlite3_bind_text(addStmt, 1, [TypeName UTF8String], -1, SQLITE_TRANSIENT);
        sqlite3_bind_text(updateStmt, 2, [DateStr UTF8String], -1, SQLITE_TRANSIENT);
        sqlite3_bind_text(updateStmt, 3, [Location UTF8String], -1, SQLITE_TRANSIENT);
        sqlite3_bind_text(updateStmt, 4, [GeoCode UTF8String], -1, SQLITE_TRANSIENT);
        sqlite3_bind_text(updateStmt, 5, [Note UTF8String], -1, SQLITE_TRANSIENT);

        //image
        NSData *imgData = UIImagePNGRepresentation(self.Image);
        int returnValue = -1;
        if(self.Image != nil)
            returnValue = sqlite3_bind_blob(updateStmt, 6, [imgData bytes], [imgData length], NULL);
        else
            returnValue = sqlite3_bind_blob(updateStmt, 6, nil, -1, NULL);

        sqlite3_bind_text(updateStmt, 7, [TypeID UTF8String], -1, SQLITE_TRANSIENT);

        sqlite3_bind_int(updateStmt, 8, ID);;

        NSLog(@"frog name %@",TypeName);
        NSLog(@"frog date %@",DateStr);
        NSLog(@"location %@",Location);
        NSLog(@"Geo code %@",GeoCode);
        NSLog(@"note %@",Note);
        NSLog(@"Img %@",Image);
        NSLog(@"Type ID %@",TypeID);
        NSLog(@"Frog ID %d",ID);


        if(returnValue != SQLITE_OK)
            NSLog(@"Not OK");

        if(SQLITE_DONE != sqlite3_step(updateStmt))
            NSAssert1(0, @"Error while updating. '%s'", sqlite3_errmsg(database));

        sqlite3_reset(updateStmt);

        isDirty = NO;
    }

    isDetailViewHydrated = NO;
}









+ (void) getInitialDataToDisplay:(NSString *)dbPath
{   
    FinderAppDelegate * appDelegate = (FinderAppDelegate *)[[UIApplication sharedApplication] delegate];
    [appDelegate.idArray removeAllObjects];
    //identifyArray = [[NSMutableArray alloc] init]; 
    if (sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK) {

        const char *sql = "SELECT ID,TypeID,TypeName,Date,Location,GeoCode,Note,Image FROM identify";
        sqlite3_stmt *selectstmt;
        if (sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK) {

            while(sqlite3_step(selectstmt) == SQLITE_ROW) 
            {
                NSInteger primaryKey = sqlite3_column_int(selectstmt, 0);
                identify *my = [[identify alloc] initWithPrimaryKey:primaryKey];
               // my.TypeID = sqlite3_column_int(selectstmt, 1);
                my.TypeID = [NSString stringWithUTF8String:(char *) sqlite3_column_text(selectstmt,1)];
                my.TypeName = [NSString stringWithUTF8String:(char *) sqlite3_column_text(selectstmt,2)];

                NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
                [formatter setDateFormat:@"yyyy-MM-dd HH:mm"];        
                NSString *dateStr = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 3)];
                my.Date = [formatter dateFromString:dateStr];//[NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 3)];

                my.Location = [NSString stringWithUTF8String:(char *) sqlite3_column_text(selectstmt, 4)];
                my.GeoCode = [NSString stringWithUTF8String:(char *) sqlite3_column_text(selectstmt, 5)];
                my.Note = [NSString stringWithUTF8String:(char *) sqlite3_column_text(selectstmt, 6)];
                const char *raw = sqlite3_column_blob(selectstmt, 7);
                int rawLen = sqlite3_column_bytes(selectstmt, 7);
                NSData *data = [NSData dataWithBytes:raw length:rawLen];
                my.Image = [[UIImage alloc] initWithData:data];

                my.isDirty = NO;

                [appDelegate.idArray addObject:my];
            }                   
        }
    } else sqlite3_close(database); //close db to release all memory
}


*** Assertion failure in -[identify saveAllData], /Users/Desmond/Desktop/Finder desmond new design 2/Finder/identify.m:241
Current language:  auto; currently objective-c

Catchpoint 2 (exception thrown).objc[58781]: EXCEPTIONS: throwing 0x130db720 (object 0x1418bab0, a NSException)
objc[58781]: EXCEPTIONS: searching through frame [ip=0x1cb3db3 sp=0xbffff4c0] for exception 0x130db700
objc[58781]: EXCEPTIONS: unwinding through frame [ip=0x1cb3db3 sp=0xbffff4c0] for exception 0x130db700
objc[58781]: EXCEPTIONS: handling exception 0x130db700 at 0x1cb3e46
objc[58781]: EXCEPTIONS: rethrowing current exception
objc[58781]: EXCEPTIONS: searching through frame [ip=0x1cb3e0f sp=0xbffff4c0] for exception 0x130db700
objc[58781]: EXCEPTIONS: terminating
objc[58781]: EXCEPTIONS: searching through frame [ip=0x1f0ef21 sp=0xbffff450] for exception 0x130db700
objc[58781]: EXCEPTIONS: catch(id)
objc[58781]: EXCEPTIONS: unwinding through frame [ip=0x1f0ef21 sp=0xbffff450] for exception 0x130db700
objc[58781]: EXCEPTIONS: handling exception 0x130db700 at 0x1f0ef33
2012-01-15 22:58:07.006 FrogFinder[58781:15b03] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error while updating. 'constraint failed''
*** First throw call stack:
(0x1d7d052 0x1f0ed0a 0x1d25a78 0x132c2db 0x93167 0x952c9 0x1d7eec9 0x9a65c2 0xbe1d54 0x1d7eec9 0x9a65c2 0x9a655a 0xa4bb76 0xa4c03f 0xa4b2fe 0x9cba30 0x9cbc56 0x9b2384 0x9a5aa9 0x27a1fa9 0x1d511c5 0x1cb6022 0x1cb490a 0x1cb3db4 0x1cb3ccb 0x27a0879 0x27a093e 0x9a3a9b 0x1f3a 0x1ed5)
  • 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-28T07:09:26+00:00Added an answer on May 28, 2026 at 7:09 am
    sqlite3_bind_text(addStmt, 1, [TypeName UTF8String], -1, SQLITE_TRANSIENT);
    sqlite3_bind_text(updateStmt, 2, [DateStr UTF8String], -1, SQLITE_TRANSIENT);
    sqlite3_bind_text(updateStmt, 3, [Location UTF8String], -1, SQLITE_TRANSIENT);
    sqlite3_bind_text(updateStmt, 4, [GeoCode UTF8String], -1, SQLITE_TRANSIENT);
    sqlite3_bind_text(updateStmt, 5, [Note UTF8String], -1, SQLITE_TRANSIENT);
    

    Are you sure that first one sould be addStmt?

    Given that that’s the only place where it’s used in the code shown, and in a section clearly designed to populate the eight updateStmt variables, I’d say it’s most likely a typo or cut-and-paste error.

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

Sidebar

Related Questions

I've been trying to debug this problem for many hours, but to no avail.
I've been spending the last few hours trying to find the memory leak in
I've been trying to deal with this problem for a couple of hours now
I've been pulling my hair out for the last few hours trying to wrestle
I have been trying to solve this problem for hours (searched here as well
I have been trying for the last few hours to get a UIAlert with
I have been trying for too many hours now myself and can't get the
I have been trying for hours to make this work but I am not
I've been trying for hours to get many-to-many relationship to save with Castle ActiveRecord.
This is crazy, I have been trying for hours to get this to work.

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.