I’m fighting with this database and i have a strange problem… If I try to insert as item name a single word, everything works fine, but if the words are 2 or more, it fails!
This is the portion of the code:
NSString *insertStatementsNS =
[NSString stringWithFormat: @"insert into \"shoppinglist\"
(item, price, groupid, dateadded) values (\"%@\", %@, %d, DATETIME('NOW'))",
name_field, price_field, [groupPicker selectedRowInComponent:0]];
I guess the problem is in the –> \”%@\” <– but I have no idea in how to fix it.
Can somebody help me?
#
I followed the steps above, but something went wrong, now I have this new error here:
NSString *itemValue = [[NSString alloc] initWithUTF8String: (char*) sqlite3_column_text(dbps, 1)];
and the program stops while starting… It can’t read anymore from the DB… what happened?
#
Ok fixed thanks to a friend… we just reset the simulator memory.
And we also solve the problem… working in another way.
Instead of using the variable “name_field” I used “itemNameField.text” (directly to the source…) and for some reason it works!
Simply use ‘%@’