我正在使用此代码从 Sqlite3 数据库中删除行,但它不起作用,插入、更新、选择查询工作正常,但删除语句在我的代码中不起作用
-(void)delete{
str=title.text;
sqlite3_stmt *selectstmt;
if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
NSString *deleteSQL = [NSString stringWithFormat: @"delete from ToDo where title=\"%@\"",str];
NSLog(@"%@",deleteSQL);
const char *sql = [deleteSQL UTF8String];
sqlite3_prepare_v2(database,sql, -1, &selectstmt, NULL);
if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK)
NSLog(@"success");
else
NSAssert1(0, @"Error while creating delete statement. '%s'", sqlite3_errmsg(database));
}
sqlite3_finalize(selectstmt);
sqlite3_close(database);
}
我究竟做错了什么?