Reputation: 1189
I am working on iPhone app. I have the SQL query:
NSString *myRed = [NSString stringWithFormat: @"%1.4f", slideR.value];
[self insertData:@"INSERT INTO colour VALUES("+myRed+")"];
It produces syntax error. How to insert a string into string. That approach in Java would have worked. Best regards
Upvotes: 1
Views: 129
Reputation: 1853
You could try writing your query and your string appended together before hand.
NSString *str = @"Your values";
NSString *query = [NSString stringWithFormat:@"INSERT INTO color VALUES(%@)", str];
[self insertData:query];
Upvotes: 1
Reputation: 6587
Try this :
NSString *myRed = [NSString stringWithFormat: @"%1.4f", slideR.value];
[self insertData:[NSString stringWithFormat:@"INSERT INTO colour VALUES(\"%@\")",myRed]];
If you don't want "
then :-
[self insertData:[NSString stringWithFormat:@"INSERT INTO colour VALUES(%@)",myRed]];
Hope it helps you.
Upvotes: 1