SQLite,无法从表中删除

时间:2011-04-13 04:46:14

标签: iphone sqlite

我想从我的数据库中删除表, 这是我的编码:

-(void)deleteDataFromDatabase:(NSString *)typeStr
{

    if ([typeStr isEqualToString:@"village"])    
    {
        NSLog(@" ======== DELETE DELETE DELETE DELETE DELETE DELETE DELETE DELETE ");
        const char *sql = "DELETE FROM Village WHERE pk=?";
        if (sqlite3_prepare_v2(dbFavoriteTab, sql, -1, &delete_statement, NULL) == SQLITE_OK) 
        {
            sqlite3_bind_int(delete_statement, 1, primaryKey);
            // Execute the query.
            int success = sqlite3_step(delete_statement);
            // Reset the statement for future use.
            sqlite3_reset(delete_statement);
            // Handle errors.
            if (success != SQLITE_DONE) 
            {    
                 NSLog(@"UNSUCCESSFILLLL IN Village");
                 NSAssert1(0, @"Error: failed to delete from database with message '%s'.", sqlite3_errmsg(database));
            }
            else {
                NSLog(@" ===  Delete Successful === ");
            }
       }
       else {
            NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
       }

   }

我无法删除数据库。控制台告诉我不可思议的村庄....我在过去3天工作..

0 个答案:

没有答案