删除后如何解锁Sqlite数据库

时间:2014-01-28 15:45:34

标签: c# sqlite windows-phone-8 winrt-xaml

当我执行删除操作时,似乎SQLite数据库被锁定,如下所示:

我需要删除两次才能刷新。在没有Sqlite数据库锁定的情况下删除的常规方法是什么?

    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;


 }







1 个答案:

答案 0 :(得分:1)

你能做点什么:

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

要等到在尝试删除下一个操作之前返回的删除操作吗?