babyDeveloper
babyDeveloper

Reputation: 33

Using SQLite from Objective-C

I am having problems writing statements, especially when updating.

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

Upvotes: 0

Views: 682

Answers (1)

martin clayton
martin clayton

Reputation: 78105

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.

Upvotes: 2

Related Questions