English 中文(简体)
deleting row in SQLite 3
原标题:

In UITableView, I want to delete a row and remove that row on database, but my query of sqlite don t works.

- (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];
    }
}   
}

Why doesn t this work?
Where I can see a good tutorial of FMDB framework?

最佳回答

FMDB is here: http://github.com/ccgus/fmdb/tree/master/src/

The sample you are looking for is also on that page; the sample is "fmdb.m".

问题回答

Try FMDB

Download the lib package and take a look in the example file included.





相关问题
sqlite3 is chopping/cutting/truncating my text columns

I have values being cut off and would like to display the full values. Sqlite3 -column -header locations.dbs " select n.namelist, f.state, t.state from names n left join locations l on l.id = n.id ...

Entity Framework with File-Based Database

I am in the process of developing a desktop application that needs a database. The application is currently targeted to SQL Express 2005 and works wonderfully. However, I m not crazy about having ...

Improve INSERT-per-second performance of SQLite

Optimizing SQLite is tricky. Bulk-insert performance of a C application can vary from 85 inserts per second to over 96,000 inserts per second! Background: We are using SQLite as part of a desktop ...

Metadata for columns in SQLite v2.8 (PHP5)

How can I get metadata / constraints (primary key and "null allowed" in particular) for each column in a SQLite v2.8 table using PHP5 (like mysql_fetch_field for MySql)? sqlite_fetch_column_types (OO:...

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签