0

我把我的代码放在这里我没有得到,警报消息有什么问题。

            NSString *deleteSQL = [NSString stringWithFormat:@"DELETE FROM FAVOURITE WHERE ID = %@", self.arrayID[[sender tag]]];
        const char *delete_stmt = [deleteSQL UTF8String];
        NSLog(@"insert query is %@",deleteSQL);
        NSLog(@"insert statement is %s",delete_stmt);
        sqlite3_prepare_v2(favouriteDB, delete_stmt, 1, &statement, NULL);
        NSLog(@"akh:%d",sqlite3_prepare_v2(favouriteDB, delete_stmt, -1, &statement, NULL));
        NSLog(@"akhdadsa:%d",SQLITE_DONE);
        sqlite3_step(statement);
        NSLog(@"this %d", sqlite3_step(statement));
        if (sqlite3_step(statement)==SQLITE_DONE)
        {
            UIAlertView *myAlert1 = [[UIAlertView alloc]initWithTitle:@"Message"
                                                              message:@"Successfully Remove From Favourite List"
                                                             delegate:self
                                                    cancelButtonTitle:@"Cancel"
                                                    otherButtonTitles:nil];

            [myAlert1 show];

        }
4

2 回答 2

1

你打sqlite3_step了两次电话。第一次调用删除记录,第二次调用失败。

于 2013-11-14T12:20:53.013 回答
0

你已经执行了两次语句。

sqlite3_step(statement);
NSLog(@"this %d", sqlite3_step(statement));
if (sqlite3_step(statement)==SQLITE_DONE)

它应该是

//sqlite3_step(statement);//delete this line 
NSLog(@"this %d", sqlite3_step(statement));
if (sqlite3_step(statement)==SQLITE_DONE)
于 2013-11-15T05:37:12.403 回答