Note that there are some explanatory texts on larger screens.

plurals
  1. POApplication crashes with Assertion Failure message while updating SQLite database
    primarykey
    data
    text
    <p>In my application i keep some data in local Sqlite db. Sqlite open, insert all working fine. but when i try to update data of a particular row/record if fails with ASSERTION FAILURE message..</p> <p><em>*</em> Assertion failure in -[gss_databaseHandler updateRecord::::], /Users/gss/Desktop/SalesPro copy/SalesPro/../gss_databaseHandler.m:210</p> <pre><code>NSString *databasePath; // Method to open a database, the database will be created if it doesn't exist -(void)initDatabase { // Create a string containing the full path to the sqlite.db inside the documents folder NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; databasePath = [documentsDirectory stringByAppendingPathComponent:@"contact1"]; // Check to see if the database file already exists bool databaseAlreadyExists = [[NSFileManager defaultManager] fileExistsAtPath:databasePath]; // Open the database and store the handle as a data member if (sqlite3_open([databasePath UTF8String], &amp;databaseHandle) == SQLITE_OK) { // Create the database if it doesn't yet exists in the file system if (!databaseAlreadyExists) { // Create the contactList table const char *sqlStatement = "CREATE TABLE IF NOT EXISTS contactList (sapCustId TEXT, sapContactId TEXT, record_ID NUMERIC PRIMARY KEY, timestamp TEXT)"; char *error; if (sqlite3_exec(databaseHandle, sqlStatement, NULL, NULL, &amp;error) == SQLITE_OK) { NSLog(@"Database and tables created."); } else { NSLog(@"Error: in creating/opening database"); } } } } - (void) updateRecord:(int)recordID:(NSString *)sapCustId:(NSString *)sapContactId:(NSString *)timestamp { [self initDatabase]; sqlite3_stmt *updateStmt = nil; if(updateStmt == nil) { const char *sql_stmt = "update contactList Set sapCustId = ?, sapContactId = ?, timestamp = ? Where record_ID = ?"; if(sqlite3_prepare_v2(databaseHandle, sql_stmt, -1, &amp;updateStmt, NULL) != SQLITE_OK) NSAssert1(0, @"Error while creating update statement. '%s'", sqlite3_errmsg(databaseHandle)); } sqlite3_bind_text(updateStmt, 0, [sapCustId UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_text(updateStmt, 1, [sapContactId UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_int(updateStmt, 2, recordID); sqlite3_bind_text(updateStmt, 3, [timestamp UTF8String], -1, SQLITE_TRANSIENT); if(SQLITE_DONE != sqlite3_step(updateStmt)) NSAssert1(0, @"Error while updating. '%s'", sqlite3_errmsg(databaseHandle)); sqlite3_finalize(updateStmt); sqlite3_close(databaseHandle); //Reclaim all memory here. [sapContactId release]; [sapCustId release]; } </code></pre> <p>Pls help!..</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload