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);
...
你可以提供一些代碼顯示你如何使用sqlite嗎? – sergio 2011-05-17 15:44:36
你在這裏寫的功能看起來是正確的。顯示1.openDatabase和2. getDBPath的函數定義。我傾向於認爲代碼中有缺失的部分。提供這兩個功能,我們應該能夠快速地找出這一個。 – SayeedHussain 2011-05-17 20:03:10