When I update some data, sometimes it throws a exception: Database is locked
.
The code below:
public int DisableSalesBySalesID(string SalesID)
{
int count = 0;
try
{
using (SQLiteConnection conn = new SQLiteConnection(ConnectionString))
{
conn.Open();
string sql = @"update SalesMaster set Disabled = '1' where SalesID=@SalesID";
using (SQLiteCommand cmd = new SQLiteCommand(sql, conn))
{
cmd.Parameters.Add(new SQLiteParameter("@SalesID", SalesID));
count = cmd.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
}
return count;
}
And, it depends on SalesID
. Some SalesID
will be OK, but the others will make the exception. Why?