iphone - Insert Special character in sqlite -
i try code.
query = [nsstring stringwithformat:@"insert bookmark(names,details) values('%@','%@')", delegate.str, delegate.str1]; nslog(@"%@",query); sqlite3_stmt *compiledstatement; if (sqlite3_open([databasepath utf8string],&database) == sqlite_ok) { if(sqlite3_prepare_v2(database,[query utf8string], -1, &compiledstatement, null) == sqlite_ok) { if(sqlite_done != sqlite3_step(compiledstatement)) nslog( @"error while inserting data: '%s'", sqlite3_errmsg(database)); else nslog(@"new data inserted"); sqlite3_reset(compiledstatement); }else { nslog( @"error while inserting '%s'", sqlite3_errmsg(database)); } sqlite3_finalize(compiledstatement); }
this want store sqlite insert bookmark(details) values('let's take example, 23456789 divided 7, 11, 13.
make triplets shown starting unit's place.
23...456...789
now add alternate triplets :
23 + 789 = 812 , 456.
difference of these 2 sums : 812 - 456 = 356
now divide difference 7, reminder 6
and divide difference 11, reminder 4
and divide difference 13, reminder 5')
and error after write line...
2013-07-25 16:38:14.653 maths tricks tips patterns[4346:c07] error while inserting 'near "s": syntax error'
how may insert special charcter please me out in advance.
you should never form sql queries manually using stringwithformat etc.
instead should use prepared statements variable binding. ensure correct encoding , avoid sql injections etc. should begin looking @ this sqlite introduction.
the basic pattern use sqlite3_prepare
followed sqlite3_bind_text
set value 1 of ?
placeholders in query.
Comments
Post a Comment