title: iOS - using sqlite database update data not working
body: <p>I would like to update some data in Xcode sqlite db. The db is successfully connected, but seems like there's something wrong in the sql statement,  it keeps returning "Failed to add contact", thanks for helping.</p>
  
  <pre><code>- (void) saveData:(id)sender
  {
  
      NSLog(@"The code runs through here!");
      sqlite3_stmt    *statement;
  
      NSString *documents = [self applicationDocumentsDirectory];
      NSString *dbPath = [documents stringByAppendingPathComponent:@"monitorDB.sqlite"];
      const char *dbpath = [dbPath cStringUsingEncoding:NSASCIIStringEncoding];
  
      if (sqlite3_open(dbpath, &amp; contactDB) == SQLITE_OK)
      {
  
          NSString *insertSQL = [NSString stringWithFormat:
                                 @"UPDATE profile SET username = \"%@\" WHERE id = 1" ,
                                 self.username.text];
  
          const char *insert_stmt = [insertSQL UTF8String];
          sqlite3_prepare_v2(contactDB, insert_stmt,
                             -1, &amp;statement, NULL);
          if (sqlite3_step(statement) == SQLITE_DONE)
          {
              self.settingStatus.text = @"Contact added";
          } else {
              self.settingStatus.text = @"Failed to add contact";
          }
          sqlite3_finalize(statement);
          sqlite3_close(contactDB);
      }   else {
          self.settingStatus.text = @"DB Not Connect";
      }
  
  
  
  }
  </code></pre>