Could someone perhaps give me an example of how to handle file locking situations when writing to an SQlite database in an application that is running on a network? I have to use SQlite databases and everything I tried (thank you Mirek for your earlier help) didn't work the way I wanted.
The basic code I use without handling file locking looks like this example for a write operation on an already existing sqlite database Z.db3 with a table named ZTABLE:
******* begin code example ********************************
Sqlite3Session z_sql3;
if(!z_sql3.Open(z.db3))
throw Exc("Can't create or open database file: Z.db3");
Sql sqlz(z_sql3);
z_sql3.Begin();
cInsertstring="INSERT INTO ZTABLE VALUES("firtst nametest, last nametest")"; // using testvariables
sqlz.ClearError();
sqlz.Execute(cInsertstring);
z_sql3.Commit();
z_sql3.Close();
*************** end of example **********************************
How and where can I check, whether the database is locked (SQL_BUSY error) and if it is locked, retry to write 5 times?
And (where) do I have to use a ROLLBACK? I am not quite sure in which cases a rollback is done automatically by sqlite.
thank you for your response. But of course I have read the page about lang_transaction on sqlite.org - and everything else that could possibly have a connection to file locking on their website and in their user mailinglist. And I googled for more information. After not being successful with everything I tried, I finally asked, if someone could provide me with an example here.