由于某些原因,我在数据库中的数据没有被删除,如果您能指出错误,我将不胜感激。
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger row = [indexPath row];
//Delete
sqlite3_stmt *stmt2;
NSArray *del = [[arr objectAtIndex:row] componentsSeparatedByString:@" "];
NSString *update1 = [NSString stringWithFormat:@"delete from survey where name='%@' and surname='%@';",[del objectAtIndex:1],[del objectAtIndex:2]];
int x = sqlite3_prepare_v2(database, [update1 UTF8String], -1, &stmt2, nil);
NSLog(@"x=%d",x);
if (sqlite3_step(stmt2) != SQLITE_DONE)
NSLog(@"Deletion Error.");
[arr removeObjectAtIndex:row];
[tblView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}非常感谢。
发布于 2011-08-16 16:49:17
是不删除数据库中的数据,还是不删除表视图中的数据。请检查您的数据库(从命令行或sqlite管理器)进行确认。
下面是代码中可能出现的错误。1)不要将NSString传递给sqlite3,像这样传递const char *query = [queryStr UTF8String]; 2)确保您正在完成/提交sqlite语句。
sqlite3_finalize(stmt)并关闭sqlite数据库。
https://stackoverflow.com/questions/7075663
复制相似问题