MilkBottle
MilkBottle

Reputation: 4332

How to unlock Sqlite Database after delete

It seems the SQLite Database is locked when I do a delete operation as below:

And I need to delete two times in order to refresh. What is the normal way to delete without any locking by the Sqlite Database?

    var ThisTrans = await db.QueryAsync<TransactionLine>("Select * From TransactionLine Where  Tid = '" + PassInTransId + "'");
    foreach (var line in ThisTrans)
    {
        var intDelStatus = db.DeleteAsync(line);
    }
    //- can  I use this to close Connection?? but it does not work!
    db = null;


--- solution

private async Task<bool> DelTransactionLine(int PassInTransId)
 {


 //--1-- delete the selected transaction line
var ThisTrans = await db.QueryAsync<TransactionLine>("Select * From TransactionLine Where  Tid = '" + PassInTransId + "'");

   foreach (var line in ThisTrans)
  {
    var intDelStatus = await db.DeleteAsync(line);
   }

 return true;


 }







Upvotes: 1

Views: 953

Answers (1)

TylerD87
TylerD87

Reputation: 1618

Can you do something like:

var ThisTrans = await db.QueryAsync<TransactionLine>("Select * From TransactionLine    Where  Tid = '" + PassInTransId + "'");
foreach (var line in ThisTrans)
{
    var intDelStatus = await db.DeleteAsync(line);
}

To await the delete operation returning before you try and delete the next one?

Upvotes: 1

Related Questions