You need to :

cout << this->SQLStatement.c_str() << endl;

Then put that SQL into the sqlite3 shell against your database and ensure you 
actually get rows back.

You also need to be sure you're looking at the same database.  Many times 
people have multiple copies and the one the program uses is not the same as 
what they think.

Is your database path complete or relative when you open the database file?

Michael D. Black
Senior Scientist
Advanced Analytics Directorate
Advanced GEOINT Solutions Operating Unit
Northrop Grumman Information Systems

________________________________________
From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on 
behalf of Arbol One [arbol...@gmail.com]
Sent: Thursday, September 06, 2012 11:14 AM
To: 'Gen eral Discussion of SQLite Database'
Subject: EXT :[sqlite] C++ - WHERE clause - update

rc = sqlite3_step(mystmt);
if(rc == SQLITE_ROW ) {
The code, in this case, does not process this statement!!?? <<--
        apstr = (const char*)sqlite3_column_text(mystmt,pos);
std::cout << apstr << std::endl;  //<<-- this is not executed
}
Table:
id | tile | fname | mname | lname |
-------------------------------------------


void ClassforSQLite3::getList(
    const Glib::ustring& db_name, // Database name
    const Glib::ustring& token) // Key word to search in the database
throw(jme::Exception) {
    Glib::ustring apstr;
    Glib::ustring sName;
    int apint;
    mySQLite3* db;
    try {
        db = new mySQLite3(db_name.c_str());
    } catch(somexception& e) {
        ...
    }

   // SQL statement
    apstr = "SELECT fname FROM ";
    apstr += this->db_table_name;
    apstr += " WHERE title = \'";
    apstr += token;
    apstr += "\' ";
    apint = 1;
    db->setStmt(apstr);
    sName = db->read_str(apint); // here is where the problem is see the method 
below


--------------------------------------------
const Glib::ustring& mySQLite3::read_str(const int pos)
throw(jme::Exception) {

    rc = sqlite3_prepare_v2(db, this->SQLStatement.c_str(), -1, &mystmt, NULL);
    if(rc != SQLITE_OK) {
        // do something
    }
    rc = sqlite3_step(mystmt);
    if(rc == SQLITE_ROW ) {
        // The code, in this case, does not process this statement!!?? <<--
        apstr = (const char*)sqlite3_column_text(mystmt,pos);
    }
    try {
        this->finalize();
    } catch(somexception& e) {
        throw e;
    }
    return apstr;
}

What am I doing wrong?

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to