let dBName = FMDatabase(path: databasePath as String)
var isUpdated = Bool()
if dBName.open()
{
isUpdated = dBName.executeUpdate("UPDATE TableName SET \(Column1)=?, \(Column2)=?, \(status)=? WHERE \(ID)=?", withArgumentsInArray: [Column1, Column2, strStatus, strID])
if isUpdated == true{
print("sucess")
}
else{
print("Error: isUpdated\(dBName.lastErrorMessage())")
print("Error: lasterrorcode \(dBName.lastErrorCode())")
}
dBName.close()
}
else
{
print("Error: \(dBName.lastErrorMessage())")
}
始終顯示錯誤未知錯誤調用sqlite3_step(5:數據庫被鎖定)歐盟。
數據庫名稱是DatabaseName.sqlite,在DocumentDirectory可用的數據庫
數據庫路徑是:
FMDB更新或插入查詢問題「未知錯誤調用sqlite3_step(5:數據庫被鎖定)歐盟」
let path = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String
let url = NSURL(fileURLWithPath: path)
let filePath = url.URLByAppendingPathComponent(dbName).path!
如果文件名DatabaseName.db工作正常,沒有任何數據庫鎖的問題,但同樣的問題,如果發現文件名是DatabaseName.sqlite
嘗試清理並再次運行您的代碼。 – Saranjith
清潔工程和派生數據中移除仍然沒有工作 –
databaseName.executeUpdate( 「UPDATE表名SET \(列1)=?\(列2)=?\(狀態)= WHERE \(ID)=?」,withArgumentsInArray: [strColumn1,strColumn2,strStatus,strID]),這裏是查詢已經調試正常 –