Note that there are some explanatory texts on larger screens.

plurals
  1. POissue during insert data by using sqlite3 in to db iPhone
    primarykey
    data
    text
    <p>I have an issue where I am trying to insert data from <code>NSMutableArra</code>y in to my database. Here is what I have so far: </p> <pre><code>- (void)insertList:(NSString*) strListName ArrayOfData:(NSMutableArray*) dataArray{ sqlite3 *database = nil; sqlite3_stmt *addStmt = nil; NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"customlists.sqlite"]; if(sqlite3_open([defaultDBPath UTF8String], &amp;database) == SQLITE_OK) { for (int i = 0; i &lt; dataArray.count; i++) { PageData *pageDta = [PageData new]; pageDta = [dataArray objectAtIndex:i]; if(addStmt == nil) { const char *sql = "insert into NewList(ListName, PageName, PageNumber, id) Values(?, ?, ?, ?)"; if(sqlite3_prepare_v2(database, sql, -1, &amp;addStmt, NULL) != SQLITE_OK) NSAssert1(0, @"Error while creating add statement. '%s'", sqlite3_errmsg(database)); } sqlite3_bind_text(addStmt, 1, [strListName UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_text(addStmt, 2, [pageDta.strNamebyFilter UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_text(addStmt, 3, [pageDta.strPageNuber UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_int(addStmt, 4, i); if(SQLITE_DONE != sqlite3_step(addStmt)) NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database)); else //SQLite provides a method to get the last primary key inserted by using sqlite3_last_insert_rowid sqlite3_last_insert_rowid(database); //Reset the add statement. sqlite3_reset(addStmt); } } else { NSLog(@"Error while opening database '%s'", sqlite3_errmsg(database)); } sqlite3_close(database); } </code></pre> <p>But after calling this function, the database is empty. Could someone help me to find the cause of this issue and potential remedies?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    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