0

UITableView,我想删除一行并删除数据库上的那一行,但我的 sqlite 查询不起作用。

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
    UIAlertView *view;

    sqlite3 *database;
    int result = sqlite3_open("/quickdatabase.sqlite", &database);
    if(result != SQLITE_OK) {
        sqlite3_close(database);
        view = [[UIAlertView alloc] initWithTitle:@"Database Error" message:@"Falha ao carregar o banco de dados.." delegate:self cancelButtonTitle:@"Cancelar" otherButtonTitles:nil];
        [view show];
        [view release];
        return;
    } else {
        NSString *query = [NSString stringWithFormat:@"DELETE FROM Enquetes WHERE Pergunta = '%@' AND Nome = '%@'", [arraySQL objectAtIndex:indexPath.row], [arrayAsk objectAtIndex:indexPath.row]];
        sqlite3_exec(database, [query UTF8String], NULL, NULL, NULL);
        sqlite3_close(database);

        view = [[UIAlertView alloc] initWithTitle:@"ArrayAsk" message:[arrayAsk objectAtIndex:indexPath.row] delegate:nil cancelButtonTitle:@"Cancelar" otherButtonTitles:nil];
        [view show];
        [view release];

        view = [[UIAlertView alloc] initWithTitle:@"ArraySQL" message:[arraySQL objectAtIndex:indexPath.row] delegate:nil cancelButtonTitle:@"Cancelar" otherButtonTitles:nil];
        [view show];
        [view release];

        [arrayAsk removeObjectAtIndex:indexPath.row];
        [arraySQL removeObjectAtIndex:indexPath.row];
        [tableView reloadData];
    }
}   
}

为什么这不起作用?
哪里可以看到 FMDB 框架的好教程?

4

2 回答 2

2

FMDB 在这里:http: //github.com/ccgus/fmdb/tree/master/src/

您正在寻找的样本也在该页面上;样本是“fmdb.m”。

于 2010-10-24T02:21:24.950 回答
0

试试 FMDB

下载 lib 包并查看包含的示例文件。

于 2010-10-24T01:49:03.873 回答