mardi 7 avril 2015

iOS How to form sqlite like statement?

Code:



@try {
if (sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK)
{
const char * sql="Select Id, Name,Designation, Skill, Credits, Selected from candidate_info where Designation like '%%%@%%'";

if(sqlite3_prepare_v2(database, sql, -1, &statement, NULL) == SQLITE_OK)
{
sqlite3_bind_text(statement, 1, [searchWord UTF8String], -1, SQLITE_TRANSIENT);
while (sqlite3_step(statement) ==SQLITE_ROW)
{


}
}
else
NSAssert1(0, @"Error in candidateinfo. '%s'", sqlite3_errmsg(database));

sqlite3_reset(statement);
}
}@catch (NSException * e) {
NSLog(@"Exception is %@, %@", [e name], [e reason]);
}@finally {
sqlite3_finalize(statement);
sqlite3_close(database);
}


I try to fetch data from sqlite based on search keyword.I tried with like statement.The query is not executing and is goes out of while loop.what is wrong with my code.thanks in advance


Aucun commentaire:

Enregistrer un commentaire