jeudi 31 mars 2016

iOS sqlite insert statments with variables

I am learning how to use sqlite in IOS

I am using the following to insert a record into a table

 int DBID =  [_db  ExecuteINSERT:@"INSERT INTO LOG(NAME , COMPANY , CATEGORY)   VALUES('txt1','txt2','txt3')"];

This works fine and adds the three strings into a row

I want to exchange the hardcoded strings for string variable but can work out what to do. I tried

NSString* myString1 = @"String1";
NSString* myString2 = @"String2";
NSString* myString3 = @"String3";
int DBID = _db  ExecuteINSERT:@"INSERT INTO LOG(NAME , COMPANY,     CATEGORY) VALUES(myString1, myString2, myString3)"];

But I get a sqlite error 1 no such column but there is as it works with hardcoded strings

any ideas where I'm going wrong?

Any help appreciated

Mark

Aucun commentaire:

Enregistrer un commentaire