Yes - that is indeed what I am doing (your 3rd scenario) - but I have tried
to close the connection first (and ignore any errors closing it) before
retrying to open. As you say, the database object I am trying to close may
not be valid so I am not able to close it first, and therefore unable to
open again. Terminating the application obviously allows it to close, so
that restarting my application now successfully opens it.

So my question is, is there any sqlite function I can call so that the
connection can be successfully closed?

thanks Serena.


On Tue, Oct 5, 2010 at 12:57 PM, Simon Slavin <slav...@bigfraud.org> wrote:

>
> On 5 Oct 2010, at 11:46am, Serena Lien wrote:
>
> > On a windows vista/win7 machine or a laptop which goes into sleep mode,
> when
> > it resumes and the application tries to open a database on a networked
> > drive, the open function returns SQLITE_CANTOPEN and SQLITE_IOERR. I
> don't
> > have a problem with this, if the OS has lost access to the network I can
> > imagine SQLITE_IOERR is quite valid. My question is, is there any way to
> > recover now from this error without forcing my application to exit and
> > restart? Any number of retries using sqlite3_open_v2 always continue to
> fail
> > with SQLITE_IOERR.
>
> SQLite doesn't do anything if you don't have any connections open.  So as
> far as SQLite is concerned, there's absolutely no difference between
>
> start application
> sleep
> wakeup
> sqlite3_open_v2()
>
> and
>
> start application
> sleep
> wakeup
> quit application
> restart application
> sqlite3_open_v2()
>
> There's just no way for SQLite to tell the difference between these two
> states.  So if something is stopping your application from accessing a file
> until it has been restarted, it's a function of the operating system rather
> than something that SQLite is doing.  However, are you perhaps doing
>
> start application
> sqlite3_open_v2()
> sleep
> wakeup
> // Oh, my open connection is now useless, I need one that works !
> sqlite3_open_v2()
>
> I can imagine that failing because SQLite thinks it already has a working
> connection to that database.  The cure would be to use sqlite3_close()
> before the new _open, though I'm not sure whether you'd have an appropriate
> connection you could use with it.  Another problem with this is that if you
> have a prepared statement for a connection, you can't close it.  You have to
> finalize first.
>
> Simon.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to