Amani
Amani

Reputation: 18123

What is wrong with sqlite3_step()?

I have a C++ program which has this function that at some point calls sqlite3_step(). It turn out that when sqlite3_step() function is reached the program clashes with a message "The program has unexpectedly finished." What exactly Am I doing wrong here?

bool Database::removeRepository(string repoName)
{
    string sql = "DELETE FROM ";
    sql += tableName + " WHERE NAME='" + repoName + "'";

    sqlite3_stmt* deleteStmt = nullptr;

    int prep_results = sqlite3_prepare_v2(connection, sql.c_str(), sql.size(), &deleteStmt, NULL);

    int results = sqlite3_step(deleteStmt);

    sqlite3_finalize(deleteStmt);

    if(results == SQLITE_DONE)
        return true;
    else
        return false;
}

Upvotes: 0

Views: 256

Answers (1)

Oliver Matthews
Oliver Matthews

Reputation: 7823

Almost certainly your sqlite3_prepare_v2 call is failing. You should check the value of prep_results and see what the value is (there is a list here)

Upvotes: 1

Related Questions