无法在iOS中的sqlite数据库中删除表

时间:2013-12-31 11:15:12

标签: ios objective-c sqlite

在我的应用程序中,每当用户按下注销按钮时,我都需要删除一个表并再次创建相同的表。为此,我使用此代码:

int result = sqlite3_open([databasePath UTF8String], &db);

if(result == SQLITE_OK)
{
    const char *dropTable = "DROP table RegisterTable";
    sqlite3_prepare_v2(db, dropTable,
                       -1, &statement, NULL);

    if (sqlite3_step(statement) == SQLITE_DONE)
    {
        NSLog(@"table dropped");
    }

    else
    {
        NSLog(@"table not dropped");
    }
}

else
{
    NSLog(@"Not opened for dropping");
}

然而,每次我得到“桌子不掉线”..

1 个答案:

答案 0 :(得分:0)

您需要检查prepare语句和步骤中的结果代码。

http://www.sqlite.org/c3ref/c_abort.html

这些评论是正确的,因为很可能该表实际上并不存在于您的数据库中。