On Tue, Jun 26, 2012 at 11:50 AM, deltagam...@gmx.net
<deltagam...@gmx.net>wrote:

> Am 26.06.2012 17:08, schrieb Pavel Ivanov:   // select count(*) from
> eventlog
>     sqltotal = "Select count(*) from eventlog";
>    rc = sqlite3_prepare(db, sqltotal, strlen(sqltotal), &stmt, NULL);
>    rc = sqlite3_step(stmt);
>    total_events = sqlite3_column_int(stmt, 0 );
>
>    std::cout << total_events << std::endl;
>
>    // select * from eventlog
>    sql = "Select id, eventdate, eventtype, counter FROM eventlog";
>    sqlite3_prepare(db, sql, strlen(sql), &stmt, NULL);
>

Error in the previous line.

You have created a prepared statement and stepped it, but you never
finalized it.  Then you overwrote the pointer to the original prepared
statement with a pointer to the new prepared statement, thus leaking the
original prepared statement.



>
>    rc = sqlite3_step(stmt);
>
> while(rc == SQLITE_ROW) {
>    id = sqlite3_column_int(stmt, 0 );
>    //cid = sqlite3_column_int(stmt, 1 );
>    evdate = (char*)sqlite3_column_text(**stmt, 1 );
>    evtype = (char*)sqlite3_column_text(**stmt, 2 );
>    evctr = sqlite3_column_int(stmt, 3 );
>
>    datetime = evdate;
>
>    datepart = datetime.Mid(0,10);
>    timepart = datetime.Mid(11,5);
>
>    std::cout << datepart << "\t" << timepart << std::endl;
>
>    newEvent.m_nEvent = the_event_ctr;
>    newEvent.m_strLastEventDate = datepart ;
>    newEvent.m_strEventTime = timepart;
>    newEvent.m_strEventType = evtype;
>    newEvent.m_nCount = evctr;
>    WriteEvent(newEvent, the_event_ctr);
>
>
>    rc = sqlite3_step(stmt);
>
>    // increment eventcounter
>    the_event_ctr++;
>
> } // while
>
> rc = sqlite3_reset(stmt);
>
> rc = sqlite3_finalize(stmt);
> rc = sqlite3_close(db);
>
> ////// sqlite3 reading //////////////////////////////**/////
>
> }
>
> ==============================**==============================**
> =============
>
> What am I missing now ? There is a rc = sqlite3_reset(stmt);  but the rc =
> sqlite3_close(db);  still returns error_code 5
> The sqlite3_exec is now comment. Do I have to "reset " and finalize this
> part normally too ? How is this done ?
>
>
> ______________________________**_________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users<http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users>
>



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

Reply via email to