所以,一个connect执行完之后要么close,要么自己处理临时文件。
处理方法:在每次执行完数据库操作后close连接,在新执行数据库操作前再open.
[db open]; [db beginTransaction]; NSString * insertsql = [self sql:@"INSERT OR IGNORE INTO %@ (`userid`,`friendid`,`isrecommend`,`isfavorite`,`isonline`,`isblock`,`isfriend`,`lastlogintime`,`lastintouchtime`,`distance`) VALUES (?,?,?)" inTable:TABLE_NAME]; [db executeUpdate:insertsql,userid,friendid,isrecommend,isfavorite,isonline,isblock,isfriend,lastlogintime,lastintouchtime,distance]; NSInteger lastInsertId = [db lastInsertRowId]; NSString * updatesql = [self sql:@"UPDATE %@ SET userid=?,friendid=?,isrecommend=?,isfavorite=?,isonline=?,isblock=?,isfriend=?,lastlogintime=?,lastintouchtime=?,distance=? WHERE `index`=?" inTable:TABLE_NAME]; [db executeUpdate:updatesql,distance,[NSNumber numberWithInt:lastInsertId]]; [db commit]; [db close];