sqlite3_prepare_v2!= SQLITE_OK [英] sqlite3_prepare_v2 != SQLITE_OK
本文介绍了sqlite3_prepare_v2!= SQLITE_OK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想问下面我的功能。
当我调用此函数时打印不可用。
你能帮帮我吗?
I wanna ask about my function below. It print NOT AVAILABLE when I call this function. Could you help me please??
static sqlite3 *database = nil;
static sqlite3_stmt *statement = nil;
- (BOOL) findNews:(NSString *)caption{
const char *dbpath = [databasePath UTF8String];
if (sqlite3_open(dbpath, &database) == SQLITE_OK)
{
NSLog(@"CAPTION ID : %@", caption);
NSString *querySQL = [NSString stringWithFormat:@"SELECT * FROM dbase WHERE CONTENT_ID = \"%@\"", caption];
const char *query_stmt = [querySQL UTF8String];
if (sqlite3_prepare_v2(database, query_stmt, -1, &statement, NULL) == SQLITE_OK)
{
if (sqlite3_step(statement) == SQLITE_ROW)
{
return YES;
}
else{
return NO;
}
sqlite3_reset(statement);
}else{
NSLog(@"NOT AVAILABLE");
}
}
return nil;
}
推荐答案
有一些理由到期sqlite3_prepare_v2!= SQLITE_OK:
There are some reason for due to which the sqlite3_prepare_v2 != SQLITE_OK :
-
该表可能不存在于数据库中。
The table may not present into the database.
查询语句错误。
查询语句中的列名错误。
Wrong column name into the query statement.
您可以通过在else中添加以下内容来使用错误声明找到确切的问题:
You can find the exact problem using error statement by putting following in else:
NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database))
这篇关于sqlite3_prepare_v2!= SQLITE_OK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文