0

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.

Henry David
  • 441
  • 1
  • 5
  • 12

1 Answers1

3

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;
}
Anupdas
  • 10,211
  • 2
  • 35
  • 60
  • Ah, thank you!! It's always something like that. Thanks for checking it out! – Henry David May 11 '13 at 18:54
  • @HenryDavid For these kind of errors you always need a third party. Happy coding. – Anupdas May 11 '13 at 18:57
  • Read the documentation on https://github.com/ccgus/fmdb about Data Sanitization. The code in this sample can pretty easily be hacked by entering SQL snippets for the values. – Johan Kool Nov 05 '13 at 08:17
  • @JohanKool Thanks for the info. Sorry I was not aware of the possibility to hack, I just debugged the error for the OP. If you don't mind can you elaborate on the issue here ? – Anupdas Nov 05 '13 at 10:02