c# - SQLite database currently in use? -
i'm writing c# programme accesses database others in network access database. sqlite database. wanted inquire whether it possible examine sqlite database if writes in it?
i had thought programme trie write sqlite db , if other writes in db, warning "access denied".
but how implement in c #?
i'm sorry bad english
you need different database: sqlite cannot handle concurrent write connection. concurrent reads.
sqlite selection embedded database local/client storage if need connection different threads/pcs need different solution sql server express.
if have utilize sqlite should set mechanism when writing grab access denied exception , automatically retrieve until configurable timeout expires.
as stated in sqlite documentation
when sqlite tries access file locked process, default behavior homecoming sqlite_busy
test sqlite_busy. here's pseudo-code illustrate solution:
while (continuetrying) { retval = sqlite_exec(db, sqlquery, callback, 0, &msg); switch (retval) { case sqlite_busy: log("[%s] sqlite_busy: sleeping fow while...", threadname); sleep bit... (use sleep(), example) break; case sqlite_ok: continuetrying = no; // we're done break; default: log("[%s] can't execute \"%s\": %s\n", threadname, sqlquery, msg); continuetrying = no; break; } } homecoming retval;
sqlite multithreading reference
c# database sqlite
No comments:
Post a Comment