无法插入cocos2dx中的sqlite3数据库

时间:2016-03-14 03:29:14

标签: sqlite cocos2d-x

sqlite3_stmt *stmt;
sqlite3 *database;
if (sqlite3_open(dtPath.c_str(), &database) == SQLITE_OK &&
    sqlite3_prepare_v2(database, String::createWithFormat("select * from data where level = %i", level + 1)->getCString(), -1, &stmt, nullptr) == SQLITE_OK &&
    sqlite3_step(stmt) == SQLITE_OK)
{
    // do somthing..
}

int statusCode  = (sqlite3_exec(database, "insert into data values(20, 'abc')", NULL, NULL, NULL));
CCLOG("%i", statusCode);

当我运行时,statusCode = 5(SQLITE_BUSY),我不知道为什么?请帮帮我!!

1 个答案:

答案 0 :(得分:0)

您是否在if正文中使用sqlite3_finalize(sqlite3_stmt *pStmt)doc