How set transaction isolation level to ReadUncommitted in SQLite?

Elan picture Elan · Mar 20, 2011 · Viewed 9.9k times · Source

According to the answer on this post it states:

Did you know that ReadUncommitted will revert to Serialized isolation unless you've enabled the shared cache and both connections are from the same thread?

Working in C#, I then went ahead and defined a DLL import as follows:

[DllImport("System.Data.SQLite.dll", CallingConvention=CallingConvention.Cdecl)]
public static extern int sqlite3_enable_shared_cache(int enable);

I called this function to enable the cache and got a successful result status of 0 when called. Nonetheless, I still get the exception "isolationlevel", when executing the below lines and attempting to set the isolation level to ReadUncommitted.

string connectionString = @"data source=d:\db\test.db3;datetimeformat=Ticks";
SQLiteConnection conn = new SQLiteConnection(connectionString);
conn.Open();
IDbTransaction tran = conn.BeginTransaction(IsolationLevel.ReadUncommitted);

This question is related to another question I posted here.

How can I pull off a query with an isolation level of ReadUncommitted in SQLite?

Answer

Elan picture Elan · Oct 26, 2011

To accomplish uncommitted reads see the following question and answer:

How perform SQLite query with a data reader without locking database?