作者:七夜绅士 | 来源:互联网 | 2023-05-29 14:37
我已经下载了SQLite学习的示例代码.我正在使用Xcode 6.1.1和iPhone 6 plus模拟器.在模拟器上运行应用程序后,我DB Error : unknown error
从查询执行中获取.下面是我收到警告的代码的一部分Comparison of constant 101 with expression of type 'BOOL' (aka 'bool') is always false.
// Execute the query.
BOOL executeQueryResults = sqlite3_step(compiledStatement);
if (executeQueryResults == SQLITE_DONE) {
// Keep the affected rows.
self.affectedRows = sqlite3_changes(sqlite3Database);
// Keep the last inserted row ID.
self.lastInsertedRowID = sqlite3_last_insert_rowid(sqlite3Database);
}
else {
// If could not execute the query show the error message on the debugger.
NSLog(@"DB Error: %s", sqlite3_errmsg(sqlite3Database));
}
可能有什么办法解决这个问题?
1> Jayprakash D..:
针对检查情况compiledStatement直接解决了这个问题:
// Execute the query.
// BOOL executeQueryResults = sqlite3_step(compiledStatement);
// if (executeQueryResults == SQLITE_DONE) {
if (sqlite3_step(compiledStatement)) {
// Keep the affected rows.
self.affectedRows = sqlite3_changes(sqlite3Database);
// Keep the last inserted row ID.
self.lastInsertedRowID = sqlite3_last_insert_rowid(sqlite3Database);
}
else {
// If could not execute the query show the error message on the debugger.
NSLog(@"DB Error: %s", sqlite3_errmsg(sqlite3Database));
}