Why not set the sqlite3* variable to NULL after a successful close.  Then you 
will always know if it is open or closed ... you can only "open" a database if 
it is currently closed (NULL) and only close a database (or do anything to it, 
really) if it is open (!=NULL).  You should do the same for statement pointers 
as well ... initialize them to 0, only prepare them if they are NULL, and only 
finalize (or do anything else to them) if they are != NULL.

Then you will always know if a pointer to a structure is valid or not.

-- 
˙uʍop-ǝpısdn sı ɹoʇıuoɯ ɹnoʎ 'sıɥʇ pɐǝɹ uɐɔ noʎ ɟı


> -----Original Message-----
> From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org]
> On Behalf Of domonic
> Sent: Friday, 7 July, 2017 20:34
> To: sqlite-users@mailinglists.sqlite.org
> Subject: Re: [sqlite] Cannot delete a Database file?
> 
> Thanks for the help.  I eventually figured this out given the points
> above.
> I simply output the open address and close address of each database I
> opened
> and closed to see if something wasn't being closed.
> 
> It turned out to be a far more simple problem in the end.  A silly one at
> that.
> 
> I was testing the closed state of a database like this.  After it closed
> on
> the first instance it would try to close the database two more times which
> is why the SQLITE_MISUSE error kept appearing.  Once that started I
> couldn't
> delete anything.
> 
> Just a stupid programming error as I suspected.   No I just test the state
> of the database once and then test the output in my if statement.
> 
> if(sqlite3_close(.......))
> {
> 
> }
> else if(sqlite3_close(......))
> {
> 
> }
> else if(sqlite3_close(......))
> {
> 
> }
> 
> 
> 
> --
> View this message in context: http://sqlite.1065341.n5.nabble.com/Cannot-
> delete-a-Database-file-tp96397p96540.html
> Sent from the SQLite mailing list archive at Nabble.com.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



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

Reply via email to