I am using c# application and running the application in server machine as windows service.When i perform insert , update delete operation from client machine it throws database lock error as below,
database is locked
at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt)
at System.Data.SQLite.SQLiteDataReader.NextResult()
at System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand cmd, CommandBehavior behave)
at System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()
at System.Data.SQLite.SQLiteTransaction.Commit()
Below is my code
public int ExecuteNonQuerySQL(SQLiteCommand cmd)
{
int ireturn = 0;
if (conn.State != ConnectionState.Open)
Open(DataFile);
using (SQLiteTransaction dbtrans = conn.BeginTransaction(IsolationLevel.ReadCommitted))
{
using (cmd.Connection=conn)
{
cmd.CommandText =cmd.CommandText ;
cmd.Transaction = dbtrans;
ireturn = cmd.ExecuteNonQuery();
dbtrans.Commit();
cmd.Dispose();
}
}
}
Please help me in this , I have done lot of googling and i must find some solution to solve this .
Regards
From the code provided it seems that you do not close the connecttion.
Pay attention also on fact, don’t know if it’s relevant in your case or not, that the
Sqlitenot very good on supporting concurentinsertsand sometimes db got lock, if you operate on it from multiple threads.