iOS sqlite3_exec中的SQLite失败

时间:2012-08-24 22:01:22

标签: ios sqlite

我有代码:

if (sqlite3_open([dbPath UTF8String], &db) == SQLITE_OK)
    {
        const char *sql_stmt = "create table contacts (id integer primary key autoincrement, name text, address text, phone text);";

        if (sqlite3_exec(db, sql_stmt, NULL, NULL, NULL) == SQLITE_OK)
        {
            av = [[UIAlertView alloc] initWithTitle:@"Success!!!" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        }
        else
        {
            av = [[UIAlertView alloc] initWithTitle:@"Error3" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        }
} else {
        av = [[UIAlertView alloc] initWithTitle:@"Error2" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    }

我到sqlite3_exec但它返回退出代码26:文件已打开但不是数据库文件。尽管如此,为什么if语句会执行呢?

提前致谢。

0 个答案:

没有答案