sqlite3_prepare_v2失败

时间:2014-06-18 12:59:18

标签: objective-c sqlite

有人可以向我解释为什么这个if语句没有触发?数据库打开很好,只是我无法从数据库中检索任何值。此外,表名也是正确的。

    if (sqlite3_prepare_v2(database, [query UTF8String], -1, &statement, nil)== SQLITE_OK) {


        while (sqlite3_step(statement) == SQLITE_ROW) {
            int uniqueId = sqlite3_column_int(statement, 0);

            char *nameChars = (char *) sqlite3_column_text(statement, 1);
            char *addressChars = (char *) sqlite3_column_text(statement, 2);

            NSString *name = [[NSString alloc] initWithUTF8String:nameChars];
            NSString *address = [[NSString alloc] initWithUTF8String:addressChars];

            PersonInfo *info = [[PersonInfo alloc] initWithUniqueID:uniqueId name:name address:address];

            [returnArray addObject:info];


        }

        sqlite3_finalize(statement);
    }
    return returnArray;
}

0 个答案:

没有答案