【问题标题】:sqlite error 14 [unable to open database file] iphone xcodesqlite 错误 14 [无法打开数据库文件] iphone xcode
【发布时间】:2011-05-17 15:41:49
【问题描述】:

您好,我在 iphone 中使用数据库。过了一段时间,我的应用程序给出了这个错误

sqlite error 14 [unable to open database file] 

我的应用程序运行良好,但有时会产生上述错误。解决方案是什么? 有代码:

[lovkid openDatabase:[appDelegate getDBPath]];
NSString *Flag = [NSString stringWithFormat:@"%@", appDelegate.selectimage];
    int recId = (int)appDelegate.Id;
    NSLog(@"recID = %d",appDelegate.Id);

    updateStmt1 = nil;
    if(updateStmt1 == nil) 
    {

        const char *sql ="UPDATE 'char' SET `Pic`=? WHERE `id`=?";
        if(sqlite3_prepare_v2(database1, sql, -1, &updateStmt1, NULL) != SQLITE_OK)
            NSAssert1(0, @"Error while creating add statement. '%s'", sqlite3_errmsg(database1));
    }
    sqlite3_bind_text(updateStmt1, 1, [Flag UTF8String], -1, SQLITE_STATIC);
    sqlite3_bind_int(updateStmt1, 2, recId);

    if(SQLITE_DONE != sqlite3_step(updateStmt1))
        NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database1));
    else
        NSLog(@"no error");



    sqlite3_reset(updateStmt1);
    sqlite3_finalize(updateStmt1);

...

【问题讨论】:

  • 你能提供一些代码来展示你是如何使用 sqlite 的吗?
  • 您在此处编写的函数看起来是正确的。显示 1.openDatabase 和 2.getDBPath 的函数定义。我倾向于认为您的代码中缺少部分。提供这两个函数,我们应该可以很快搞清楚这个。

标签: iphone xcode sqlite


【解决方案1】:

你需要试试我在post的回答

并确保你在你的应用程序中编写两个函数(post),这样你的应用程序将打开一次数据库

让我知道它是否有效

干杯:)

【讨论】:

    【解决方案2】:

    可以通过更改存储数据库文件的目录中的设置来解决SQLite错误14。

    【讨论】:

      猜你喜欢
      • 2020-07-03
      • 1970-01-01
      • 2020-09-13
      • 2013-01-03
      • 2021-10-15
      • 1970-01-01
      • 2015-02-16
      • 1970-01-01
      • 2011-05-24
      相关资源
      最近更新 更多