Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8856787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:26:09+00:00 2026-06-14T14:26:09+00:00

In my c++ page, i have a preparement statement sqlite3_stmt *sqlstmt; which returns SQLITE_OK

  • 0

In my c++ page, i have a preparement statement

sqlite3_stmt *sqlstmt;

which returns SQLITE_OK when it is passed data through the int

string query;
query = "select * from A;"
int rc = sqlite3_prepare_v2(db,query.c_str(),0,&stmt,0);
if (SQLITE_OK != rc ){ return; } 

function.

Then start the next line.

int rc;
rc = sqlite3_step(sqlstmt);
//rc = 21 here.

An except from the SQLITE3 documentation. My current version is 3.07.14.01 i believe.

http://www.sqlite.org/c3ref/step.html

SQLITE_MISUSE means that the this routine was called inappropriately. Perhaps it was called on a prepared statement that has already been finalized or on one that had previously returned SQLITE_ERROR or SQLITE_DONE. Or it could be the case that the same database connection is being used by two or more threads at the same moment in time.

For all versions of SQLite up to and including 3.6.23.1, a call to sqlite3_reset() was required after sqlite3_step() returned anything other than SQLITE_ROW before any subsequent invocation of sqlite3_step(). Failure to reset the prepared statement using sqlite3_reset() would result in an SQLITE_MISUSE return from sqlite3_step(). But after version 3.6.23.1, sqlite3_step() began calling sqlite3_reset() automatically in this circumstance rather than returning SQLITE_MISUSE. This is not considered a compatibility break because any application that ever receives an SQLITE_MISUSE error is broken by definition. The SQLITE_OMIT_AUTORESET compile-time option can be used to restore the legacy behavior.

actual code function

vector cDataInterpretor::getWorkingSet(int userID){
vector t_val;
vector retVal;
sqlite3 *db;
int rc;
rc = sqlite3_open(databasePath.c_str(), &db);
if(rc != SQLITE_OK){
sqlite3_close(db);
return t_val;
}
string query = “select * from insp_Assets;”;
char* errorMessage;

sqlite3_stmt *sqlstmt;
//rc = sqlite3_exec(db, query.c_str(), 0, 0, &errorMessage);

cout << "preparing statement"<<endl;
rc = sqlite3_prepare_v2(db, query.c_str(), 0, &sqlstmt, 0);
cout << "prepare code: "<<rc << endl;
if(rc != SQLITE_OK){
    sqlite3_close(db);
    return t_val;
}
cout << "Resetting call." <<endl;
rc = sqlite3_reset(sqlstmt);

cout << "about to start while"<<endl;
rc =sqlite3_step(sqlstmt);
cout << rc<<"|" << SQLITE_ROW <<"|" << SQLITE_OK <<"|"<<SQLITE_DONE<< endl;
while(rc == SQLITE_ROW){
    //sset retVal (id,name,code,typeId,reportTypeId,parentAsset);
    int id,typeID, reportTypeId;
    id = sqlite3_column_int(sqlstmt, 0);
    string name(reinterpret_cast<char const *>(sqlite3_column_text(sqlstmt, 1)));
    string code(reinterpret_cast<char const *>(sqlite3_column_text(sqlstmt, 2)));
    typeID = sqlite3_column_int(sqlstmt, 3);
    reportTypeId = sqlite3_column_int(sqlstmt, 4);
    string parentAsset(reinterpret_cast<const char *>(sqlite3_column_text(sqlstmt, 5)));
    cout <<"Fetched Asset Data: "<< id <<"|"<<name<<"|"<<code<<"|"<<typeID<<"|"<<reportTypeId<<"|"<<parentAsset << endl;
    Asset a (id, name, code, typeID, reportTypeId, parentAsset);
    retVal.push_back(a);
    rc = sqlite3_step(sqlstmt);
}
cout << "while ended, about to return."<<endl;
sqlite3_close(db);
return retVal;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:26:10+00:00Added an answer on June 14, 2026 at 2:26 pm

    You are incorrectly calling sqlite3_prepare_v2(). From the documentation:

    If the nByte argument is less than zero, then zSql is read up to the
    first zero terminator. If nByte is non-negative, then it is the
    maximum number of bytes read from zSql. When nByte is non-negative,
    the zSql string ends at either the first ‘\000’ or ‘\u0000’ character
    or the nByte-th byte, whichever comes first.

    So, your prepare statement should look like this (easiest change, at least):

    int rc = sqlite3_prepare_v2(
       db,
       query.c_str(),
       -1,   // instructs SQLITE to read the entire statement up to the \0 terminator
       &stmt,
       0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have page where I use model which can have different types (depending by
I have page named page--news.tpl.php, which i created for my news page. But after
I have page (Default1.aspx) in which I am redirecting to another page (Default2.aspx) using
I have page which is redirected from htaccess. now I can pass the German
I have Page Tab App, which has a landing page with a Log In
I have a navigation menu within a page on my site, which has JavaScript
We have a web page which is often reloaded by clicking F5 or Ctrl-R
I have one search page. page have 6 textboxes as a search criteria which
i have a parser which parse a blog page which is parsing others page
if u add this to web.config, then if a page have gone through long

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.