title: Objective-C Issue with deleting data from SQLITE database - result code 5
body: <p>I am experiencing issues with deleting a row / data record from an SQLite database located on the iPhone. I followed advice given in the following <a href="https://stackoverflow.com/questions/6083932/deleting-data-from-sqlite-table-iphone-sdk">post</a>, but the result code from SQLite is 5. From the SQLite reference manual, 5 means:</p>
  
  <p>SQLITE_BUSY         5   /* The database file is locked */</p>
  
  <p>Has anyone else come across this problem or have any ideas why this would be the case? </p>
  
  <p>Here is an excerpt of my code (dbrc is set to 5):</p>
  
  <pre><code>    NSString *retrievedContactID = [archivedContact objectForKey:@"contact_id"];
  
      sqlite3 *database = [FollowUPAppDelegate checkAndCreateDatabase];
      NSString *deleteSQL = [NSString stringWithFormat:@"DELETE FROM Contacts WHERE contact_id = %@", retrievedContactID];
  
      const char *delete_stmt = [deleteSQL UTF8String];
      sqlite3_stmt *compiledStatement;
      int dbrc; //database return code
  
      dbrc = sqlite3_prepare_v2(database, delete_stmt, -1, &amp;compiledStatement, NULL);
      dbrc = sqlite3_step(compiledStatement);
      sqlite3_finalize(compiledStatement);
      compiledStatement = NULL;
  
  
      if (dbrc != 101) {  //anything except 101 (SQLITE_DONE for delete, *not* SQLITE_OK)
          NSLog(@"Error deleting contact from database: result code %i", dbrc);
          return;
      }
      else {
          NSLog(@"deleted the customer from datasets");
      }
  
      sqlite3_close(database);
  </code></pre>