SQLite:数据库在iOS中被锁定

时间:2014-03-28 19:47:06

标签: ios sqlite

我的错误是数据库在sqlite中被锁定。我知道过去曾问过这个问题,但我找不到错误。我在日志中收到的错误是database is locked。非常感谢帮助。

-(void) createCreditCardInfoTable{
    char *err;

    [self openDB];

    NSString *sql = [NSString stringWithFormat:@"CREATE TABLE IF NOT EXISTS tblCreditCardInfo (creditCardID INTEGER PRIMARY KEY AUTOINCREMENT, customerID TEXT "
                     ", creditCardNumber TEXT, expirationDate TEXT, ccvCode TEXT);"];

    if(sqlite3_exec(db, [sql UTF8String], NULL, NULL, &err) != SQLITE_OK)
    {
        NSLog(@"didn't delete error: %s", sqlite3_errmsg(db));
        // sqlite3_close(db);
        NSLog(@"%@",sql);
        //NSAssert(0, @"Couldn't create tblCreditCardInfo table");
        NSLog(@"Couldn't create tblCreditCardInfo table");
    }
    else
    {
        NSLog(@"tblCreditCardInfo table created");
        sqlite3_close(db);

    }
}

这是openDB的代码:

-(void) openDB{
    if(sqlite3_open([[self filePath] UTF8String], &db) != SQLITE_OK)
    {
        sqlite3_close(db);
        NSAssert(0, @"DB Failed to Open");
        NSLog(@"database failed to open");
    }
    else{
        NSLog(@"database opened");
        NSLog(@"didn't delete error: %s", sqlite3_errmsg(db));
    }
}

非常感谢任何帮助。感谢。

0 个答案:

没有答案