CAVALO SCHMIDT wrote:
In the following simple C code (in Console program):sqlite3 *db; int ret = sqlite3_open("dict.db", &db); sqlite3_stmt *stmt; char sql[256]; sprintf(sql, "%s", "select * from a where a = 'key1'"); int rc = sqlite3_prepare(db, sql, 0, &stmt, 0); while(sqlite3_step(stmt) == SQLITE_ROW) { printf( (char *)sqlite3_column_text(stmt, 1) ); }; sqlite3_finalize(stmt); sqlite3_close(db); I must have made a very simple beginner mistake, because an error happens. sqlite3_prepare returns SQLITE_OK, but sqlite3_step returns 21 = SQLITE_MISUSE. Can anyone tell me what I did wrong? It happens with any database I test it with. Just for information, sqlite3_exec works perfectly.
You have called sqlite3_prepare incorrectly. The third argument is the length of the sql string if it is positive. To have sqlite scan until the end of the string you need to pass a negative number. Tyr this instead.
int rc = sqlite3_prepare(db, sql, -1, &stmt, 0); HTH Dennis Cote ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------

