I have prepared a select statement.
sqlite3_prepare(db, "SELECT symbol,image FROM test WHERE template=? AND field=?", -1, &stmt, 0);
sqlite3_bind_text16(stmt, 1, pParams->pszFile, -1, SQLITE_STATIC);
sqlite3_bind_text16(stmt, 2, pParams->pszFieldId, -1, SQLITE_STATIC);
How to go about iterating through the results?
int rc = sqlite3_prepare(db, "SELECT symbol,image FROM test WHERE template=? AND field=?", -1, &stmt, 0);
sqlite3_bind_text16(stmt, 1, pParams->pszFile, -1, SQLITE_STATIC);
sqlite3_bind_text16(stmt, 2, pParams->pszFieldId, -1, SQLITE_STATIC);
if(rc != SQLITE_OK)
{
fprintf(stderr, "SQL error: %s\n", sqlite3_errmsg(db));
return;
}
rc = sqlite3_step(stmt);
int ncols = sqlite3_column_count(stmt);
while(rc == SQLITE_ROW)
{
for(i=0; i < ncols; i++)
{
fprintf(stderr, "'%s' ", sqlite3_column_text(stmt, i));
}
fprintf(stderr, "\n");
rc = sqlite3_step(stmt);
}
sqlite3_finalize(stmt);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With