I want to retrieve the number of records in a table,
but dont know how to get access to the result of " select count(*) from tablename "



========================================================
#include "db_functions.h"

//using namespace std;


void select_count( ) {

    int rc, i, ncols, id;
    char *sql;
    char *evdate, *evtype;
    int evctr;

    sqlite3 *db;
    sqlite3_stmt *stmt;



    sql = "Select count(*) from eventlog";
    sqlite3_open("ah.db", &db);

    sqlite3_prepare(db, sql, strlen(sql), &stmt, NULL);


    char create_sql[] = "CREATE TABLE if not exists eventlog ("
        "id INTEGER PRIMARY KEY,"
        "eventdate DATETIME default current_timestamp,"
        "eventtype TEXT,"
        "counter INTEGER"
        ")";

    rc = sqlite3_exec(db, create_sql, NULL, NULL, NULL);

    rc = sqlite3_prepare(db, sql, strlen(sql), &stmt, NULL);


//    while(rc == SQLITE_ROW) {



    rc = sqlite3_step(stmt);


//    } // while


    sqlite3_finalize(stmt);
    sqlite3_close(db);
}

====================================================





_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to