簡體   English   中英

無法使用消息“數據庫已使用sqlite3在ios中鎖定數據庫”來打開數據庫

[英]Failed to open database with message 'database is locked in ios using sqlite3

即使在打開數據庫之前我已經明確關閉數據庫,我仍然面臨以下與iO中的sqlite數據庫有關的問題,但是我仍然一次又一次地遇到相同的問題。

由於未捕獲的異常“ NSInternalInconsistencyException”而終止應用程序,原因:“無法打開消息為“數據庫已鎖定”的數據庫。

這是我的代碼

sqlite3_stmt *statement;
const char *dbpath = [databasePath UTF8String];
if (sqlite3_open(dbpath, &contactDB) == SQLITE_OK)
{
    const char *insert_stmt = "INSERT INTO myusertbl (username,password) VALUES (?,?)";
    if(sqlite3_prepare_v2(contactDB, insert_stmt, -1, &statement, NULL)==SQLITE_OK)
    {
        sqlite3_bind_text( statement,1, [self.username UTF8String], -1, SQLITE_TRANSIENT);
        sqlite3_bind_text( statement,2, [self.userpass   UTF8String], -1, SQLITE_TRANSIENT);
    }
    if (sqlite3_step(statement) == SQLITE_DONE)
    {
        NSLog(@"You have Sucessfully saved!");
    }
    else
    {
        NSLog(@"Failed to Save!");
        NSAssert1(0, @"Failed to open database with message '%s'.",           sqlite3_errmsg(contactDB));
    }
    sqlite3_finalize(statement);
    statement = nil;
}

請幫我。

您確定要使用sqlite3_close API關閉數據庫嗎?

sqlite3_close(contactDB); 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM