iOS sqlite/FMDB update not working

纵然是瞬间 提交于 2019-12-08 11:35:18

问题


This isn't as easy and specific to ask as I'd like, but I'm really stuck with something. I followed this tutorial, recreating it very similar for an iPad app: http://www.highoncoding.com/Articles/836_Persisting_iOS_Application_Data_in_SQLite_Database_Using_FMDB.aspx

The issue I'm running into is the edit customer and save portion. I've thrown in NSLog's with the customers new name that I edit, and it gets pushed through all the functions, so I'm thinking it's breaking in the update command.

It could also possibly be with the customerID, or some minuscule setting in the storyboard that I'd never find.

If anyone has any ideas, let me know. I can zip up my code for anyone as well.


回答1:


The issue is with your update query, your each column values were not separated with commas.

-(BOOL) updateClient:(Client *) client
{
    FMDatabase *db = [FMDatabase databaseWithPath:[Utility getDatabasePath]];

    [db open];

    BOOL success = [db executeUpdate:[NSString stringWithFormat:@"UPDATE clients SET name = '%@', phone = '%@', address = '%@', email = '%@', notes = '%@' WHERE id = %d", client.Name, client.Phone, client.Address, client.Email, client.Notes, client.clientId]];

    [db close];
    return success;
}


来源:https://stackoverflow.com/questions/16499614/ios-sqlite-fmdb-update-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!