On 2 Jul 2017, at 5:06am, domonic <abdom...@hotmail.com> wrote:

> The database file I am trying to delete is in use when I try to delete it, so
> it's obviously still open.

From whqt you wrote so far, you might have an anti-virus package installed 
which is still checking the database when you try to delete it.  Anti-virus 
packages are meant to uderstand this situation and cope with it by hooking the 
delete routine, but sometimes you can fool them.

> This is what I've done.
> 
> I have made my connection to the database (sqlite3 *handle) global. 
> If this is the case then just before I delete the file I could close the
> connection (sqlite3_close(handle))
> 
> But this returns the error SQLITE_MISUSE.
> 
> What conditions would incur such an error.

Use debugging commands to check that the handle you’re passing to _close() is 
the same value you got from opening the file.  Something may have changed the 
value of your global variable.

Check your code to make sure you have run _finalize() on all statements 
associated with that handle.  And check the result returned by each one to make 
sure it worked.

If you execute _close() immediately after _open(), do you still get 
SQLITE_MISUSE ?  If not, then gradually move the _close() further and further 
down your code until it stops working.

If neither of the above are the problem, you’re probably stomping on memory 
which SQLite is using for its own purposes.  This could be the result of any 
misused pointers or arrays in your code.

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

Reply via email to