Thanks, I have created NSString and added the id value, then for creating statement I have converted NSString to const char* by UTF8String but the it seems it does no t work as sqlite3_prepare_v2 does not return SQLITE_OK.
Thanks for response. Igor Tandetnik wrote: > > "anna_shahinyan" > <annashahin...@yandex.ru> wrote in > message news:23171280.p...@talk.nabble.com >> I have tried the following but does not help: >> >> sqlite3_stmt *stmt; >> const char *sql_check = "SELECT * FROM MY_DATABASE WHERE id=?"; >> NSString *name = nil; >> if(sqlite3_prepare_v2(myDatabase, sql_check, -1, &stmt, NULL) == >> SQLITE_OK) { >> if (sqlite3_step(stmt) == SQLITE_NOTFOUND) { >> NSLog(@"Not found"); >> } >> } > > You apparently want to check for a record with a particular ID - aren't > you surprised that your code doesn't mention the actual ID anywhere? > > Your query has a parameter placeholder (the '?' sign). You need to bind > its value before running the statement - see sqlite3_bind_int. > > Finally, sqlite3_step would return SQLITE_DONE when there are no > records, not SQLITE_NOTFOUND. > > Igor Tandetnik > > > > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > -- View this message in context: http://www.nabble.com/Find-in-SQLite-database-tp23171280p23175323.html Sent from the SQLite mailing list archive at Nabble.com. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users