2011-05-17 170 views
1

嗨,我在iphone中使用數據庫。沿着時間後,我申請了這個錯誤sqlite錯誤14 [無法打開數據庫文件] iphone xcode

sqlite error 14 [unable to open database file] 

我的應用程序會不錯,但有些時候,它產生上述error.What解決? 有代碼:

[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); 

...

+0

你可以提供一些代碼顯示你如何使用sqlite嗎? – sergio 2011-05-17 15:44:36

+0

你在這裏寫的功能看起來是正確的。顯示1.openDatabase和2. getDBPath的函數定義。我傾向於認爲代碼中有缺失的部分。提供這兩個功能,我們應該能夠快速地找出這一個。 – SayeedHussain 2011-05-17 20:03:10

回答

1

以及ü需要從post

試試我的回答,並確保你所寫的(職位)的兩個功能在烏爾應用delgate這樣烏爾應用程序將打開DB一次

讓我知道,如果它的工作

乾杯:)

0

SQLite錯誤14可以通過更改存儲數據庫文件的目錄中的設置來解決。

相關問題