Using SQLite from Objective-C
I am having problems writing statements, especially when updating.
- I want to update a column with a parameter, but I don't know the special characters to use like
@
or%d
.
I tried to do:
const char *sqlStatement = [[NSString stringWithFormat:
@"update lugar set frecuencia ='d%'aumentador Where idLugar = '%d'",
idLugarParametro] cStringUsingEncoding:NSUTF8StringEncoding];
But I get a problem with: frecuencia ='d%'aumentador
- How can I find a guide or tutorial 开发者_如何学JAVAfor using this special characters for creation statements? (Using Objective C specifically.)
Here's An Introduction To The SQLite C/C++ Interface.
Here's the Apple documentation for NSString stringWithFormat, and string format specifiers.
I note that it seems you typed d%
, but probably meant %d
for the format specifier (you might need an extra space in there too), and that
you've only supplied one arg (idLugarParametro), but your format string has two specifiers:
------------------------------1v------------------------------2v
update lugar set frecuencia ='%d' aumentador Where idLugar = '%d'
so you need to supply two values - the new frecuencia value is not there.
Lastly, suggest that you look in to the use of prepared statements once you've got the hang of the basics - see the SQLite docs.
精彩评论