File I/O Error - SQlite

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
wjjw73
Posts: 22
Joined: Fri 17 Aug 2012 09:51

File I/O Error - SQlite

Post by wjjw73 » Wed 22 Aug 2012 05:35

Hello,
I have an application which should run on an USB stick.
So FM-Win-Application and SQliste DB.
On Application start I connect to the DB and keep it open.
Open tables which I need and keep it open
Now the problem:
When I remove the USB stick (for which reason ever) and connect again and try to access the DB I always get an file io error (On Error).

What can I do to prevent this? Always close the DB/tables after each request/insert??
Or can I "quietly" reconnect to DB after "On Error"??

ZEuS
Devart Team
Posts: 240
Joined: Thu 05 Apr 2012 07:32

Re: File I/O Error - SQlite

Post by ZEuS » Thu 23 Aug 2012 12:18

SQLite is a file-oriented database. Commonly, it uses a single database file, but in addition there is a couple of temporary files which are implicitly created and used by SQLite during processing a database ( http://www.sqlite.org/tempfiles.html ).
Therefore, the situation where an I/O error arises is quite expected when removing/inserting a USB drive.
To avoid this, please try to perform the following steps:
- in the UniConnection.OnError event handler set the Fail variable to False in order to avoid the error message;
- set the UniConnection.Options.DisconnectedMode property to True. When setting the property to True, a connection is opened only when it is required and datasets remain open when the connection is closed. Note, that in this case you should not re-open the connection explicitly in the OnError event handler.
You can find more information about working in the disconnected mode in the "Disconnected Mode" article in the UniDAC documentation.

Post Reply