[英]How to post and get data from SQLite database on objective-c iphone app?
[英]Objective-C Issue with deleting data from SQLITE database - result code 5
我從iPhone上的SQLite數據庫刪除行/數據記錄時遇到問題。 我遵循了以下文章中給出的建議,但是SQLite的結果代碼為5。從SQLite參考手冊中,5表示:
SQLITE_BUSY 5 / *數據庫文件已鎖定* /
有沒有其他人遇到這個問題或有任何想法為什么會這樣呢?
這是我的代碼的摘錄(dbrc設置為5):
NSString *retrievedContactID = [archivedContact objectForKey:@"contact_id"];
sqlite3 *database = [FollowUPAppDelegate checkAndCreateDatabase];
NSString *deleteSQL = [NSString stringWithFormat:@"DELETE FROM Contacts WHERE contact_id = %@", retrievedContactID];
const char *delete_stmt = [deleteSQL UTF8String];
sqlite3_stmt *compiledStatement;
int dbrc; //database return code
dbrc = sqlite3_prepare_v2(database, delete_stmt, -1, &compiledStatement, NULL);
dbrc = sqlite3_step(compiledStatement);
sqlite3_finalize(compiledStatement);
compiledStatement = NULL;
if (dbrc != 101) { //anything except 101 (SQLITE_DONE for delete, *not* SQLITE_OK)
NSLog(@"Error deleting contact from database: result code %i", dbrc);
return;
}
else {
NSLog(@"deleted the customer from datasets");
}
sqlite3_close(database);
這意味着。 您的數據庫正在被其他進程使用。 您必須停止其他過程並繼續。 我可以舉一個例子。 當您從應用程序訪問數據庫時,如果嘗試使用某些外部sqlite管理器更改內容,則會收到此繁忙錯誤。 解決此問題的方法是,停止您的應用並嘗試。
您的問題是相似的。 您的數據庫已被其他進程鎖定。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.