On 22 Jun 2010, at 11:18pm, Sam Carleton wrote: > void CSQLiteDB::Close() > { > if(m_db) > { > sqlite3 *db = m_db; > m_db = NULL;
Does not do what you are trying to do. Just use m_db. > int rc = sqlite3_close(db); > > while( rc == SQLITE_BUSY) > { > // set rc to something that will exit the while loop > rc = SQLITE_OK; > sqlite3_stmt * stmt = sqlite3_next_stmt(db, NULL); > > if(stmt != NULL) > { > rc = sqlite3_finalize(stmt); > if(rc == SQLITE_OK) > { > rc = sqlite3_close(db); > } > } > } > } > } void CSQLiteDB::Close() { if(m_db) { rc = sqlite3_close(m_db); while (rc == SQLITE_BUSY) // maybe include _LOCKED { sqlite3_stmt *stmt = sqlite3_next_stmt(db, NULL); if (stmt) sqlite3_finalize(stmt); // don't trap, can't handle it anyway msleep(1000 * .25); // give other threads time rc = sqlite3_close(m_db); } if (rc != SQLITE_OK) reportSQLiteError(rc, "while closing connection"); } } Note: I have not tried the above code. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users