> Can you
> make absolutely sure sqlite3_close() has been called correctly and does not 
> return
> an error ?

As a matter of fact, Simon, for some reason, whenever I call it in this 
particular function (and I call this function a lot), it returns an error.  The 
error is (both surprisingly and unsurprisingly) "unable to close due to 
unfinalized statements."

Here's the code, as simplified as I know how to make it (you will see that the 
one prepared statement is finalized):

   int          Result;

   std::string InsertStatement = "Insert into blah blah blah";  //  The Insert 
statement works whenever I can get a connection, which is the first 523 
attempts.

   Result = sqlite3_initialize();

   sqlite3 *db_ptr;
   Result = 0;

   Result = sqlite3_open_v2(DBEnginePath, &db_ptr, SQLITE_OPEN_READWRITE, 
NULL); 

   sqlite3_stmt *ResultStmt;
   Result = sqlite3_prepare_v2(db_ptr, InsertStatement.c_str(), -1, 
&ResultStmt, NULL);


   Result = sqlite3_step(ResultStmt);
   if((Result != SQLITE_DONE) && (Result != SQLITE_ROW))
   {
Do some error stuff
   }

  sqlite3_reset(   ResultStmt);

//  based on your comments earlier, the tests were added as you see here.
   Result = sqlite3_finalize(ResultStmt);
   if(Result != SQLITE_OK)
   {
       fprintf(stderr, "Did not finalize"):   //  Never saw this
   }

   sqlite3_close(       db_ptr);
   if(Result != SQLITE_OK)
   {
       fprintf(stderr, "failed to close sqlite db ptr"):   //  As far as I can 
tell, this msg showed up with the processing of every record.
   }


I'm not sure where I've gone wrong.

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

Reply via email to